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
 SaveToFilePSD does not store the correct thumbnail
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Sybren

34 Posts

Posted - Nov 03 2012 :  03:18:17  Show Profile  Reply
Hi,
When I save a multilayered ImageEnView in the PSD format (IO.SaveToFilePSD) it does not correctly update the thumbnail. I tried to update the EXIFThumbnail, but it only takes the the active layer, not the full layered picture. It is correctly shown in Photoshop, but reading it back in an ImageEnMView, it doesn't show the correct picture.

The issue occurs when I load an existing psd file into the ImageEnView, then change layer content with other bitmaps, and save again. Then finally updates a MView to reflect the changes. The MView does not show the changed layers, it shows the original layered file. If necessary I can share such a 'wrong' file, created with SaveToFilePSD.

w2m

USA
1990 Posts

Posted - Nov 03 2012 :  06:21:49  Show Profile  Reply
You do not provide enough information to figure this out. Show some code. Do you add the bitmaps in to ImageEnMView then Save with ImageEnMView.MIO?

Hint: Use ImageEnMView to store all the layers and save with ImageEnMView.MIO.SaveToFilePDF. Only use ImageEnView to preview selected ImageEnMView images. If you make any changes to the bitmap in ImageEnView, update ImageEnMView before saving the file.

William Miller
Go to Top of Page

Sybren

34 Posts

Posted - Nov 03 2012 :  07:02:14  Show Profile  Reply
Thanks for the quick response. Here is some code:

ImageEnMView1: multiviewer with bitmaps
ImageEnMView2: multiviewer of the saved psd files
ImageEnView1: the layers compilation of (transparent) bitmap artwork

I drag a bitmap to ImageEnView1 to swap the layer.

onDragDrop:

procedure TForm1.ImageEnMView1DragDrop(Sender, Source: TObject; X, Y: Integer);
...
{ filename is derived from ImageEnMView1 }
{ idx is the target layer, set by a different control, not relevant here }
ImgEnIO1.LoadFromFile(filename); { I use a generic IO component for all IO actions, to be used across some parts of the application }
with ImageEnView1 do
begin
LayersCurrent := idx;
IEBitmap.Assign(ImgEnIO1.IEBitmap);
Update;
end;
end;

After this action the ImageEnView1 correctly shows the swap of layer content in layer idx.

Then I save the full multilayered ImageEnView1 as a psd file:

procedure TForm1.SaveAsPSD(Sender: TObject);
...
{ psdfile is a string after an inputbox was called }
ImageEnView1.Update;
ImageEnView1.IO.SaveToFilePSD(psdfile);
{ then I update the MViewer again }
with ImageEnMView2 do
begin
AppendImage(psdfile);
ImageFileName[ImageEnMView1.ImageCount-1] := psdfile;
Update;
end;
end;

It now still shows the original ImageEnView1 before the bitmap was swapped in layer idx. Even after restarting the application the ImageEnMView2 still shows the original picture. Opening this psdfile in Photoshop shows the correctly swapped layer at idx. So the swap and save was certainly successful.
Do you need such a file to check?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 03 2012 :  07:31:59  Show Profile  Reply
Maybe you need to add ImageEnView1.IO.Params.PSD_LoadLayers:=true; Read about PSD in the help file.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Sybren

34 Posts

Posted - Nov 03 2012 :  07:47:32  Show Profile  Reply
I did at loading. Forgot to put it in the code on this forum, but it's in.
Should I send my file that reads correctly in Photoshop but not in ImageEnMView?
Thx.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 03 2012 :  07:48:54  Show Profile  Reply
yes... I am building a small demo to experiment with.

William Miller
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 03 2012 :  08:41:11  Show Profile  Reply
Did you send the file?

William Miller
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 03 2012 :  10:31:15  Show Profile  Reply
I can add a layer, move the layer, delete a layer and replace an image in a layer in a psd file and save it to a file. When the file is reloaded into ImageEnView and the ImageEnMView is refilled the images are correct in both the ImageEnView and in the ImageEnMView. If you would like the demo let me know.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Sybren

34 Posts

Posted - Nov 03 2012 :  10:58:34  Show Profile  Reply
Great! I've sent you the file that caused my call for support. I'm certainly interested in your code.
thx
Sybren
Go to Top of Page

Sybren

34 Posts

Posted - Nov 05 2012 :  15:19:05  Show Profile  Reply
It got it finally solved. It appears that the thumbnail is not updated at saving. Updating the EXIF doesn't help, so after changing the MView StoreType setting from ietThumb to ietNormal it finally shows the full updated file.
Silly error perhaps, but I would expect an update of the thumbnail when saving. Now I need to find how to update the PSD thumbnail.
Go to Top of Page

fab

1310 Posts

Posted - Nov 06 2012 :  01:18:31  Show Profile  Reply
If you need to update EXIF thumbnail then call UpdateEXIFThumbnail. Example:

ImageEnView1.IO.LoadFromFile('input.jpg');
ImageEnView1.Proc...do something...
ImageEnView1.IO.Params.UpdateEXIFThumbnail;
ImageEnView1.IO.SaveToFile('output.jpg');

Of course it should work also with PSD.
Go to Top of Page

Sybren

34 Posts

Posted - Nov 06 2012 :  13:54:36  Show Profile  Reply
When I use ImageEnView1.IO.Params.UpdateEXIFThumbnail it will only add/update a thumbnail of the current layer (or layer 0, I'm not so sure). Reading the saved PSD file back as StoreType ieThumb will only display the thumbnail of one layer, not of the comp. Could this be a bug in ImageEn 4.1.0?
When I select StoreType ietNormal it correctly displays the saved PSD file. It makes sense because this store type will read the entire comp from file.
Go to Top of Page

fab

1310 Posts

Posted - Nov 06 2012 :  13:58:48  Show Profile  Reply
If you have more than one layer, you should merge layers before call UpdateEXIFThumbnail. This is not a bug of 4.x, this is the previous and current behavior.
Go to Top of Page

Sybren

34 Posts

Posted - Nov 06 2012 :  14:11:46  Show Profile  Reply
True, I should. But I don't want to merge layers and 'destroy' a lot of carefully designed and positioned layers. Instead, I should then save as .lyr, then flatten the image and create a thumbnail, then read the .lyr again. I should expect that ImageEn does this in a smarter way. But perhaps I'm too demanding :-)
Go to Top of Page

fab

1310 Posts

Posted - Nov 06 2012 :  14:21:30  Show Profile  Reply
Actually merging layers is an intensive task. This way allows user to choice whether update the thumbnail from main layer or using all layers.
Go to Top of Page

yogiyang

India
728 Posts

Posted - Nov 07 2012 :  07:26:55  Show Profile  Reply
@Sybren,

What you suggest is more CPU intensive. I would suggest you to Save UnDo and then Flatten Image. Get the thumbnail that you want and store is somewhere and then UnDo.

HTH



Yogi Yang
Go to Top of Page

Sybren

34 Posts

Posted - Nov 07 2012 :  11:04:59  Show Profile  Reply
I'm not sure it will work. This is my simple test. I've loaded an original multi-layered psd file (checked for content, it was correct), then updated a layer, then added this code:

ImageEnView1.Proc.AutoUndo := true;
ImageEnView1.LayersMergeAll;
ImageEnView1.IO.Params.UpdateEXIFThumbnail;
ImageEnView1.Proc.Undo(true);
ImageEnView1.IO.SaveToFilePSD(psdfile);
ImageEnView1.Proc.AutoUndo := false;

And as a result it saved the file as a single layered psd file. But with the correct thumbnail in the MView. Perhaps I'm missing something here?

Sybren
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 07 2012 :  11:45:29  Show Profile  Reply
I am not sure if AutoUndo actually saves an undo when calling LayersMergeAll because LayersMergeAll is not an ImageEnView1.Proc. If AutoUndo isTrue, only image processing (Proc) and load operations automatically call the SaveUndo method. So try ImageEnView1.Proc.SaveUndo();

So your code becomes:
ImageEnView1.Proc.SaveUndo();
ImageEnView1.LayersMergeAll;
ImageEnView1.IO.Params.UpdateEXIFThumbnail;
ImageEnView1.Proc.Undo(true);
ImageEnView1.IO.SaveToFilePSD(psdfile);


I did not test this code... you may not be able to undo a LayersMergeAll, so in this case this code will not work.

I do not understand why you want to use thumbnail mode? If I were you I would use normal mode and your problems are solved.

Generally I turn off AutoUndo and increase the UndoLimit to 99 for most projects. When ever the image is changed I call ImageEnView1.SaveUndo(). That way you are sure the undo has been saved.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Sybren

34 Posts

Posted - Nov 07 2012 :  13:38:51  Show Profile  Reply
Good thinking. I tested this variation, but alas, no result. It keeps on saving a flat .psd file of the last used layer only. Your assumption may be true: when not .Proc it doesn't store the full layered undo. Just the active layer itself.

I can of course apply the ietNormal mode, but it adds to the memory usage, and I've got pretty big .psd files, and it can also become quite a lot of such files. For the moment the ietNormal StoreMode appears to be the only simple solution for this.

I have a workable solution, but I'd hoped for a more lean solution. Nevertheless I'm very grateful for all your support!

Thanks
Sybren
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: