Performance, Pixel Cache, memory for multi layer PSD

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
curelc

Performance, Pixel Cache, memory for multi layer PSD

Post by curelc »

Hi,

I have this PSD file with 25 million pixels and about 40 layers. Reading through the Architecture tutorial, I understand that a pixel cache is build for processing an image, loading all pixels. Let's say I use Q8, so that would be 25 mil x 4 channels Bytes of memory at least.
Here are my questions/comments.

1) Does the number of layers play a role ? it would seem to be as the physical memory consumption is actually beyond 100M. It actually uses all of it so the above formula should include in the product the number of layers too I guess.

2) The first step in my process is extracting the color space, then creating a JPEG thumbnail for it. These steps both take around 30 minutes or more each. Are there any configurations or tips I missed to somehow switch to a different "way" of processing that would speed up things?
Or building this pixel cache is at the center of things, it needs that memory and that it's it?

I mean I read the part saying "In most cases, the benefits of the pixel cache typically outweigh any disadvantages." but I have used two other libraries that convert this file in 1 sec. it also take 1 sec to extract the colorspace. This sort of performance I would think holds a lot of weight in the balance of things - assuming the result is of decent quality of course.

I also know that overall ImageMagick is a superior library to the other ones I have used but wish there would be an option for fast processing - it looks possible. I am no expert in image processing and I mean no offense. I am convinced the architecture is solid.

Thanks
Cristian
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by magick »

Assume your image is named image.psd. Try this command:
  • convert 'image.psd[0]' image.jpg
How many seconds / minutes does that command take to complete?
curelc

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by curelc »

Thanks a lot mister magick :).

I was looking for something like that but I missed "Selecting Frames" as I was looking more at the options of 'convert

Anyway, that command takes 1 minute. The same duration if I use "identify - verbose image.psd[0]" to see the color space.

What does this actually do ? Do I lose something ? Maybe I need to understand better the layers and psd but it does not look like it gets just one layer. It would be like this layer [0] blends all the other visible ones.

I appreciate the prompt response.
genesung

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by genesung »

Hi,

PSD index improves the performance a lot, but I encountered another issue. When I resize the PSD[0] image, it seems like that it lost some channels. It looks like that an invisible channel is overwriting the visible channels. I am not sure whether it is related to the index or not.

Any idea on this?

Thanks,
jerry gs chung
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by fmw42 »

suggest you post a link to your problematic PSD file so it can be examined and tested independently
genesung

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by genesung »

Thanks for your prompt response.

Unfortunately, I cannot post the PSD file. The file owner does not allow it.

By the way, I found a possible performance enhancement in psd.c

Below line 905: if ((image_info->number_scenes == 1) && (image_info->scene == 0))

It is reading the file off with ReadBlobByte, but I think it might be better to use SeekBlob. With my experiment, it improves a lot (about 9~10 times faster with my test file).

Thanks,
jerry
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by magick »

We can't use SeekBlob() because not all files are seekable (stdin for example).
genesung

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by genesung »

At least, we can use ReadBlob() with some buffer rather than ReadBlobByte(). Futhermore, SeekBlob() is already used in psd.c.

About the invisible channel issue, at the bottom side of ReadPSDImage()

for (i=0; i < (ssize_t) psd_info.channels; i++)
{
status=ReadPSDLayer(image,psd_info.channels,i,offsets+i*image->rows,
exception);

Don't we need to check the visibility of channels here?

Thanks,
jerry
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Performance, Pixel Cache, memory for multi layer PSD

Post by magick »

At least, we can use ReadBlob() with some buffer rather than ReadBlobByte(). Futhermore, SeekBlob() is already used in psd.c.
Already done. Look for the patch in ImageMagick 6.6.4-3 Beta available by sometime tomorrow.
Post Reply