Forum: Ruby on Rails RMagick Setting Quality or Compression

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
TomRossi7 (Guest)
on 2007-05-16 21:41
(Received via mailing list)
I am trying to dynamically set the compression or quality of an image
when displaying it.  I have seen in the RMagick documentation how to
set the quality only when writing the file to disk.  How can I set the
quality dynamically or set the compression?

The method "image.quality=" does not exist and
"image.compression_type=" is not in the documentation.  I have tried
image.compression= Magick::CompressionType.new('JPEGCompression',50),
but that doesn't work.

Thanks!

--Tom
TomRossi7 (Guest)
on 2007-05-16 22:25
(Received via mailing list)
Okay, I've figured out how to set the quality with the .to_blob
method:

    image.to_blob { self.quality=50 }

That will let me do what I am trying to do.  If there are any RMagick
pros out there, I still would like to know
1) How can you change the JPEGCompression?  It looks like it is always
set to 5.
2) What is the difference between setting the JPEGCompression and
Quality?  Is one better than the other?

Thanks,
Tom
Russell N. (Guest)
on 2007-05-17 00:20
(Received via mailing list)
img.write("image.jpg"){self.quality = 75}

:)
This topic is locked and can not be replied to.