# RMagick Setting JPEGCompression

**URL:** <https://www.ruby-forum.com/t/rmagick-setting-jpegcompression/104323>\
**Category:** Ruby\
**Created:** [May 16, 2007, 7:40pm UTC](https://www.ruby-forum.com/t/rmagick-setting-jpegcompression/104323 "2007-05-16T19:40:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 16, 2007, 7:40pm UTC](https://www.ruby-forum.com/t/rmagick-setting-jpegcompression/104323/1 "2007-05-16T19:40:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 17, 2007, 12:01am UTC](https://www.ruby-forum.com/t/rmagick-setting-jpegcompression/104323/2 "2007-05-17T00:01:30Z")

</div>

TomRossi7 wrote:

> 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?

You can’t. The only time you can specify the compression level is as an  
optional argument to Image#write or Image#to\_blob.
