How Do I Change Output Resolution On Existing Image With RMagick/ImageMagick?
ImageMagick and RMagick both have a setting/attribute for "density", which
is what they call resolution. I can pass it a value of 200 and it should
set the resolution to 200x200 when the image is written to either a file
or to_blob.
In the Rails console I can load the image, then set the density, and if I
check it, it will tell me the density (originally 300x300) is now 200x200,
but when I write it out to a file, the resolution is 300x300.
The only way I've successfully been able to change the resolution is by
creating a new image of the same width and height, then overlay the
original image. This, however, distorts the output, no matter what
settings I use (I tried setting the original to fully opaque, the "new" to
fully transparent, and even used the CopyCompositeOperation, which should
fully replace the "new" image).
I have tried setting density like this: image.density = "200"
And like this image.write("test.jpg") {self.density="200"} And both.
Nothing works... any ideas?
No comments:
Post a Comment