Forum: Ruby compressing files

Posted by Adriana Mikolaskova (mikolaskova)
on 2012-11-30 10:56
Hello,

i want to show the jpeg-compression data loss on different images...

for this purpose I'm trying to save an image several times with a ruby
(rmagick) script. The problem is: the image is compressed once and there
is no data loss after the first saving...

Here is the code I'm trying to work with. What could be wrong? How can I
change the code, that there is a difference in saving 7 times or 18
times...f.e.

$i = 1
$num = 700

while $i < $num  do

   puts $i

img = Image.read("mypath/line1.jpeg").first
img.rotate!(90)
img.write("mypath/line1.jpeg"){ self.quality = 50 }
img.destroy!
img = nil
GC.start

$i +=1
end

Thanks

Adriana
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.