ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to maintain image layer transparency?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

whisper1980

USA
67 Posts

Posted - Jun 05 2021 :  17:33:18  Show Profile  Reply
I'd like to compress the ien file. As an example, I have a 54KB jpg image. If I add a small 1K png image layer to it, the merged jpg image stays small at 54KB or so, but the ien layer file is 488KB.

If I reload that large ien layer file, the transparency is retained in the image layer. However, since I save the ien file into a database, it grows too big too fast (my users add and edit lots of images). So, I tried setting the ien compression to JPG, but while small, like a more manageable 69KB small, I lose the image layer transparency.

What is the recommended IEN Compression setting to make the ien file small and still retain he transparency of image layers?

It would be nice, for the ien layers file, to compress the base image in its original format, such as jpg, and the image layers in their original format, such as png. Right now, with no compression, it seems to save as an uncompressed bitmap. Is that right?

ImageEnView1.IO.Params.IEN_Compression := ioJPEG;
ImageEnView1.IO.SaveToFileIEN(fLayerFilename);

ImageEn 10.0.1
Delphi 10.4.2

Eric

xequte

6141 Posts

Posted - Jun 07 2021 :  22:09:05  Show Profile  Reply
Hi Eric

You should set IEN_Compression to ioPNG for the smallest size with Alpha support.

Note: You cannot use the WIC imaging engine if IEN_Compression=ioPNG as it does not support offset streams.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

whisper1980

USA
67 Posts

Posted - Jun 08 2021 :  13:21:53  Show Profile  Reply
Possibly worse. Starting with a 55KB jpg image, adding a 1.6KB PNG image and saving.
ien file with no Compression = 505KB,
ien file with PNG compression = 510KB

After each edit, the merged JPG stayed at 55KB.

Eric
Go to Top of Page

whisper1980

USA
67 Posts

Posted - Jun 08 2021 :  13:49:42  Show Profile  Reply
I also tried the following with no change:
IEGlobalSettings().PNGEngine := ieenNative;

and also tried ieenAuto
Go to Top of Page

whisper1980

USA
67 Posts

Posted - Jun 08 2021 :  14:18:31  Show Profile  Reply
Not the best idea, but I tried modifying LayerSaveToStream and it does what I need (small file size and maintains layer transparency), so if you can add a parameter for compression of Layer0 vs other layers, it would be helpful:
if i = 0 then
  Layers[i].SaveToStream( Stream, False, ioJPEG )
else
  Layers[i].SaveToStream( Stream, False, CompressionFormat );


Eric
Go to Top of Page

whisper1980

USA
67 Posts

Posted - Jun 08 2021 :  14:33:45  Show Profile  Reply
Actually, this might be better (for me) without needing a new parameter. I pass in the original base image format, e.g. ioJPEG, as my CompressionFormat and modified LayterSaveToStream like this, using internal compression for other layers:
if i = 0 then
  Layers[i].SaveToStream( Stream, False, CompressionFormat )
else
  Layers[i].SaveToStream( Stream, False, -1 );

Eric
Go to Top of Page

xequte

6141 Posts

Posted - Jun 09 2021 :  17:51:35  Show Profile  Reply
Hi Eric

IEN format is not an "End format", i.e. it is a format used for editing and then once editing is complete a user would output to an end format, e.g. JPEG.

For this reason, I'd be reluctant to use a lossy format like JPEG, as each time the IEN file is saved a bit of the quality would be lost.

Your usage may be different, of course.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

whisper1980

USA
67 Posts

Posted - Jun 09 2021 :  18:01:37  Show Profile  Reply
We use ImageEN for inspectors to add annotations to photos they took in the field. They need to be able to re-edit the images and move previous objects around or delete them, so we keep both the IEN and the merged JPG versions in the database (our old version did not allow that and the #1 complaint was that they couldn't re-edit the added objects like some other image editors allow). A slight loss in one or two re-edits is not a big deal (and never noticed any degradation myself) since the photos are typically just 640x480 and about 3" wide in the PDF report.

Eric
Go to Top of Page

xequte

6141 Posts

Posted - Jun 14 2021 :  20:52:54  Show Profile  Reply
Hi Eric

You raise a good point. From 10.0.2 you can offset IEN_Compression by 10000 to use JPEG for non-transparent layers, e.g.

// Use PNG as the compression format for layers with transparency, otherwise use JPEG
ImageEnView1.IO.Params.IEN_Compression := 10000 + ioPNG;
ImageEnView1.IO.SaveToFileIEN('D:\Layers.ien');


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: