Page 1 of 1

image.read(size, file) not working

Posted: 2007-09-23T12:10:05-07:00
by tomf
I can read images with image.read("test.jpg") without a problem. My problem however is, that when I'm using image.read("50x50", "test.jpg") the first argument (the geometry) is simply ignored. The image still has the same size as without specifing the geometry. Forcing the resize "50x50!" also has no effect.

The second problem is, that without specifing the geometry the image also has a wrong size - no matter how big the image is after reading it I get 512 columns/width by using image.columns();

Am I doing something wrong here?

Re: image.read(size, file) not working

Posted: 2007-09-23T13:24:43-07:00
by magick
For the JPEG format, the size if just a hint. To get the exact size you want, use image.resize().

Re: image.read(size, file) not working

Posted: 2007-09-24T20:40:00-07:00
by anthony
In fact from personal experience. the size hint will be enlarged to the next power of 2 and the image read will be between that size and the next power higher still!

For example a size hint of 200x100 will become 256x128 and image read in will be somewhere between that size and 512x256.

It basically stops image reading from using up ALL your memory for very large JPEGs, until you can then resize it to size you really want.

Also the image read in will be a 'point sampled' image, not resized so quality will be bad. I recommend the size hint be at least twice the final size wanted.