DPI has *absolutely nothing* to do with filesize.
Infact, the DPI value in an image file doesn't actually affect the
image at all, and can be modified (with an appropriate editor) without
changing the image in any way.
Just re-reading this thread and trying to figure it out... can you
recap on what you're trying to achieve and what's going wrong?
(i.e. Am I right in thinking this BMP stuff is just a rabbit hole
caused by attempting to find a workaround to a problem with resizing a
JPG?)
Thanks,
Peter
Really. Look at this: http://bpsite.net/misc/dpi_filesize.png - the
filesizes are *identical* because the image has not been changed for
either of them!
Don't confuse resizing the dimensions of an image with changing its
DPI / PPI values.
Unfortunately, the resize dialog in Photoshop causes confusion in this
- because it locks the physical (print) size of an image, it means
that modifying the pixels/inch value will also alter the image pixel
dimensions (and visa versa) - but it is important to know that it is
the changing of pixel width/height values (from 2592x3872 to 778x1162)
which modifies the filesize of the image (because there are less
pixels to store data about, and thus lower quality).
The change to the DPI is just a side-effect due to Photoshop locking
the physical size.
First thing to re-iterate (if I haven't gone on about it enough) is
that DPI has nothing to do with quality of a digital image. It only
has relevance at the printing stage (when the image is converted to
physical dots on a page).
So, whilst it shouldn't be the culprit for the bad image quality, it
is a little odd that cfimage is changing the dpi to 72 - and perhaps
odder that in all my tests it is changing the dpi to 96 (even with an
image originally set to 72).
However, I've experimented with an assortment of jpg and png images,
with the read/resize/write code from your original post (variables and
formatting changed, but same functionality), and I'm not getting any
quality issues.
So, I guess first thing to check is what Railo versions we have, in
case there is some change to versions of the image libraries used
between these versions.
For these tests it looks like I'm running against Railo 3.1.0.012
(should really download the updates) on Java 1.6.0_11 and Win XP sp2.
Also, can the original image you were trying to resize be made public?
(in case there is some odd issue with the image itself, as Michael suggested)
Yep, this is definitely a bug - here is some simple code to reproduce
the problem:
<cfset InputImage = "./images/random_bitmap.bmp" />
<cfset OutputImage = "./images/new_image.bmp" />
<cfimage
source = "#InputImage#"
name = "MyBitmap"
/>
<cfimage
action = "write"
source = "#MyBitmap#"
destination = "#OutputImage#"
/>
This throws the error "No compression type set!" and creates a
zero-byte new_image.bmp file.
The quality attribute should be optional for any uncompressed format
(I'd probably even suggest it should be optional (default to 1) for
compressed formats too.)
If someone wants to create a Jira issue for this specific issue that'd
be great - if not I'll do it after I've had some dinner. :)
I'm testing with the image you sent, but so far I don't get the issue
with a straight cfimage/resize - the quality of the output image has
no problems.