ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Creating a "lighter" version of an heavy image.

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
mastinf Posted - Apr 15 2016 : 09:34:32
hello,

in my application i have some reports where i have a lot of images.
Images can be heavy. the results is that the reports creation time can be high. I was thinking, in the acquisition process of the images, to save two versions: an high quality one and a lighter one (i'll use one or the other as requred by situation).
I see there's a resample method in TImageEnProc, but in this way the size of the image will be reduced. I don't want this. I want the size in inches (pixels divided by DPI) remains the same. Is there a specific ImageEn method (or some Delphi code) that you can share with me ?

thanks

Roberto

Roberto Nicchi
Master Informatica
Italy
5   L A T E S T    R E P L I E S    (Newest First)
mastinf Posted - Apr 18 2016 : 05:15:46
After a bit of coding i have decided to use the resample method recalculating manually the new DPI to avoid the image's size in inches is changed. It seems working.
The last ting that i have to solve is: when i have to resample ? Images are not all the same. Some could be heavy (maybe taken with a digital camera). Others could be low res so i don't have to resample. My first tought was to consider the megapixels. If the image is larger that a a predefinied megapixel value i will resample... I'm open to any suggestion. thanks

Roberto Nicchi
Master Informatica
Italy
mastinf Posted - Apr 18 2016 : 03:19:12
Hello, thanks for all your suggestions.
Images are in JPG format / 24bit colors.
As rmklever said it's not really important the space used on disk.
It's important the space used in memory. Less image is used and less the elaborations on images will be faster. A report with many images will (i suppose) use less total memory and will be created in a shorter time. The ChangeResolution suggested by xequte could be a solution.
I'm experimenting.

thanks

Roberto Nicchi
Master Informatica
Italy
xequte Posted - Apr 17 2016 : 16:13:20
Hi Roberto

It is true that if you halve the size of an image but double its DPI then print it, theoretically both images would print at the same size (but one with less quality). But the image is still half the size. DPI is generally only relevant when printing, and should only be thought of as advice for how an image should be scaled (for example, doubling the DPI of an image, should give the same effect as printing at 200% size).

Anyway, to handle this in MLK, you can resample the image and then set new DPI values, or you can call ChangeResolution():

http://www.imageen.com/help/TImageEnView.ChangeResolution.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
rmklever Posted - Apr 17 2016 : 11:34:09
Hi Roberto,

what do you mean by heavy and light image? If you save an image in png and use 20MB or you save the same picture as a jpeg file using 200kB it will still use the same amount of memory when loaded back into memory.

The only option I see that might be of use is to convert it into 256 colors, but if the report generator convert every image into 24 bit it will not make any difference.

There are not enough information in your post too come up with a good answear.


Roy M Klever
Klever on Delphi - www.rmklever.com
w2m Posted - Apr 15 2016 : 11:15:21
The answer to your question depends on the file types you choose and the quality needed. It is not a simple question to answer. The most effective way to reduce file size is to resample the image to smaller dimensions. Having said that, the next most effective parameters are the file type, the bit depth and the compression level, JPEG Quality or PNG_Compression. Png images and jpeg images are probably the best. Bit depths of 256 color may help reduce file size.

You will have to experiment with these parameters to see what the result is to produce the smallest files with the highest quality.
// Sets color-mapped 256 colors
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;

// Sets JPEG quality of 70% 
ImageEnView1.IO.Params.JPEG_Quality := 70;
ImageEnView1.IO.SaveToFile('D:\output.jpg');

If your images are jpeg, then reduce the Jpeg quality to a level that produces the results that are needed for your use and display of the images in your application. If 256 color images are not acceptable then use 24-bit.
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 3;

The file size probably will be larger with 24-bit but only you can decide on the quality of the image you need.

If your files are PNG then experiment with PNG Compression. (iexBitmaps.pas)
ImageEnView1.IO.Params.PNG_Compression := 9;

See the help file in IO.Params for the various parameters that can be set depending on the file type.

An alternative to consider is using TImageEnMView to display thumbnails of jpg images, by using a StoreType property of ietFastThumb or ietThumb. The default is ietNormal which does not use thumbnails but require more time for loading. Then if you need to display the entire original image, load the file into TImageEnView using the filename stored in the ImageEnMView1.MIO.Params[x].Filename parameter. When the StoreType peoperty is set to ietFastThumb or ietThumb if you load the image into TImageEnView, the quality and the size of the image will be poor. That way you can have both fast loading of images (thumbnails) and still have access the full original image from the filename.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development