Page 1 of 1

PSD File Size Too Large

Posted: 2013-07-01T06:11:24-07:00
by joshk
Hello,

I am creating a layered PSD file comprised of PNG files also generated in IM. I noticed that the file size of the PSD created by IM is ~47MB. I opened the file in GIMP, v 2.8 for OS X, and exported the file as a PSD (making no changes to the file) and the resulting file is ~1MB. Why the difference?

I took a look at identify for each PSD file and noticed that the IM created PSD has a larger histogram than the GIMP exported one...why is there "extra" data and how can create a similarly sized file in IM?

Info:
ImageMagick 6.7.8-8 2012-08-22 Q16 running on linux
GIMP V2.8 for OS X
Images: https://www.dropbox.com/sh/wclz3we1q7d7t39/SaYRVcuFXl
IM cmd:

Code: Select all

convert \
	\( -background white /tmp/bleeds/background.png /tmp/bleeds/logo_box.png /tmp/bleeds/inside_border.png /tmp/bleeds/outside_border.png -flatten \) \
	\( -label "Background" /tmp/bleeds/background.png \) \
	\( -label "Logo Box" /tmp/bleeds/logo_box.png \) \
	\( -label "Inner Border" /tmp/bleeds/inside_border.png \) \
	\( -label "Outer Border" /tmp/bleeds/outside_border.png \) \
	+repage -colorspace sRGB -alpha set '/tmp/bleeds/IM-created.psd'
PSD file must be 150 DPI and 1755x1346 px

I can provide the IM cmds for each of the PNG files if needed. Any help is appreciated. Thanks!

Josh

Re: PSD File Size Too Large

Posted: 2013-07-01T16:54:50-07:00
by snibgo
It seems IM doesn't provide any compression to the PSD file. Windows 7 script, IM v6.8.6-0:

Code: Select all

%IM%convert -verbose ^
   ( -background white background.png logo_box.png inside_border.png outside_border.png -flatten ) ^
   ( -label "Background" background.png ) ^
   ( -label "Logo Box" logo_box.png ) ^
   ( -label "Inner Border" inside_border.png ) ^
   ( -label "Outer Border" outside_border.png ) ^
   -compress Zip ^
   +repage -colorspace sRGB -alpha set IM-created2.tiff

%IM%convert IM-created2.tiff IM-created2.psd

dir IM-created* /od

02/07/2013  00:47            84,539 IM-created2.tiff
02/07/2013  00:47        37,817,614 IM-created2.psd
It creates a tiff of a sensible (compressed) size, but the PSD file is not compressed (much).

Perhaps one of the other "convert -list compress" options works for PSD.

Re: PSD File Size Too Large

Posted: 2013-07-02T05:55:56-07:00
by joshk
I did try to compress the PSD file using

Code: Select all

-compress RLE
It reduced the file size by ~10MB; a 20% reduction is good, but I want the file size to be closer to ~1MB that GIMP produces. According to the identify below, GIMP uses RLE compression; maybe the compression algorithms are different?

Here's the `identify -verbose` output for the IM created PSD and the GIMP PSD:

https://www.dropbox.com/s/7km30ancpjbhi ... reated.txt
https://www.dropbox.com/s/yiy8cbvn7bj64 ... export.txt

I tried creating tiff files instead of png but that seemed to only increase the file size of the final image to ~100MB (note: I did not do any tiff compression or compression on the resulting PSD file).

Re: PSD File Size Too Large

Posted: 2013-07-02T06:42:34-07:00
by snibgo
RLE seems to be the only compression available within IM for PSD, and it is not very effective for this image.

Zip compression for TIFF is effective for this image, creating a file of 84 k bytes.

So, if you want small files and can work with TIFF instead of PSD, then TIFF is a better option.

(Note: I am testing with IM 6.8.6-0, a far more recent version than yours.)

Re: PSD File Size Too Large

Posted: 2013-07-02T07:25:20-07:00
by joshk
Unfortunately, PSD is the chosen format. It's great that the TIFF files can be compressed to such a small size; I wish the same could be done for PSDs!

I have quite a few PSD files and I would rather not have to open them all in GIMP and export them to get the reduced file size.

Could the problem be related to the PNGs? Maybe there is something about their construction that leads to poor compression within IM?

Code: Select all

convert -density 150x150 -size 1756x1346 xc:none \
\( -fill none -stroke red -strokewidth 4 -draw "rectangle 51,51 825,1277" \) \
\( -fill none -stroke red -strokewidth 4 -draw "rectangle 932,51 1706,1277" \) \
+repage /tmp/bleeds/inside_border.png

Code: Select all

convert -density 150x150 -size 1756x1346 xc:none \
\( -fill none -stroke black -strokewidth 4 -draw "rectangle 0,0 867,1342" \) \
\( -gravity East -fill none -stroke black -strokewidth 4 -draw "rectangle 889,0 1752,1342" \) \
+repage /tmp/bleeds/outside_border.png

Code: Select all

convert -density 150x150 -size 1756x1346 xc:none \
\( -strokewidth 4 -draw "stroke blue fill none rectangle 287,1021 583,1169" \) \
\( -pointsize 10 -gravity Center -draw "stroke none fill blue translate -878,-673 text 435,1070 'Logo Location'" \) \
\( -pointsize 10 -gravity Center -draw "stroke none fill blue translate -878,-673 text 435,1120 'Horizontally Centered'" \) \
+repage /tmp/bleeds/logo_box.png

Code: Select all

convert -density 150x150 -size 1756x1346 xc:none\
\( -stroke none -strokewidth 4 -fill grey -draw "rectangle 0,0 871.0638,1346.4573" \) \
\( -gravity East -stroke none -strokewidth 4 -fill grey -draw "rectangle 885,0 1756,1346" \) \
+repage /tmp/bleeds/background.png

Re: PSD File Size Too Large

Posted: 2013-07-02T07:43:25-07:00
by snibgo
I note that the PSD created by Gimp has RLE compression. I don't know why IM's RLE compression is worse than Gimp's. I can see nothing in your source files that might be a problem.

However, Gimp is 8-bit only, so I tried your command ...

Code: Select all

"%IMG8%convert" -verbose ^
   ( -background white background.png logo_box.png inside_border.png outside_border.png -flatten ) ^
   ( -label "Background" background.png ) ^
   ( -label "Logo Box" logo_box.png ) ^
   ( -label "Inner Border" inside_border.png ) ^
   ( -label "Outer Border" outside_border.png ) ^
   +repage -colorspace sRGB -alpha set ^
   -compress RLE ^
  IM-created2.psd
... using IM Q8. I only have an ancient version (v6.6.1-1). The result is 10.2 MB. Perhaps a more recent Q8 version would be better.

Re: PSD File Size Too Large

Posted: 2013-07-02T07:49:04-07:00
by joshk
I will eventually be zipping the PSD files so I went ahead and zipped one up.

https://www.dropbox.com/s/uv9ajbdbps5w3 ... ed.psd.zip
https://www.dropbox.com/s/xdemm7b7ouamg ... st.psd.zip

The IM created PSD is zipped to 114KB and the GIMP exported PSD is 27KB. I'm not going to fuss over ~90KB. However, I do not want to accept this as the solution. There has to be a reason/explanation why the PSDs produced are so large and why the RLE compression cannot produce the ~1MB file that GIMP can (the GIMP exported PSD is noted as being RLE compressed in the identify output - maybe IM's RLE implementation is not as efficient?).

Re: PSD File Size Too Large

Posted: 2013-07-02T08:30:10-07:00
by magick
Add '-depth 8' to your command line.

Re: PSD File Size Too Large

Posted: 2013-07-02T08:33:57-07:00
by snibgo
An IM developer would need to comment. An experiment suggests a problem is with multiple images in a single PSD. Windows 7, IM v6.8.6-0:

Code: Select all

%IM%convert -size 1000x1000 xc:red -compress RLE r1.tiff
%IM%convert -size 1000x1000 xc:red -compress RLE r1.psd

%IM%convert -size 1000x1000 xc:red xc:blue -compress RLE r2.tiff
%IM%convert -size 1000x1000 xc:red xc:blue -compress RLE r2.psd
File sizes:

Code: Select all

02/07/2013  16:29         4,008,284 r1.tiff
02/07/2013  16:29           105,068 r1.psd
02/07/2013  16:29         8,016,584 r2.tiff
02/07/2013  16:29         6,105,152 r2.psd

Re: PSD File Size Too Large

Posted: 2013-07-02T08:35:28-07:00
by joshk
snibgo,

Your post about 8/16bit made me check the identify output again...found something interesting. Please open:

gimp-export.txt : https://www.dropbox.com/s/yiy8cbvn7bj64 ... export.txt
IM-created.txt : https://www.dropbox.com/s/7km30ancpjbhi ... reated.txt
IM-created-RLE.txt : https://www.dropbox.com/s/hm35uq0byu0jm ... ed-RLE.txt

Search for "Scene: 2 of 5" in each of the files. Below the scene text will be a 'Compression' label. The gimp export shows this layer as being RLE compressed but the IM-created-RLE.psd image does not show the layer as being compressed. Maybe the compress option does not work well with a layered PSD? Searching on "Compression: RLE" in the IM-created-RLE file results in one instance whereas the gimp-export results in 5 instances.

Here's the compressed PSD: https://www.dropbox.com/s/sa51buvockel2 ... ed-RLE.psd.

magick,

Code: Select all

convert \
	\( -background white /tmp/bleeds/background.png /tmp/bleeds/logo_box.png /tmp/bleeds/inside_border.png /tmp/bleeds/outside_border.png -flatten \) \
	\( -label "Background" /tmp/bleeds/background.png \) \
	\( -label "Logo Box" /tmp/bleeds/logo_box.png \) \
	\( -label "Inner Border" /tmp/bleeds/inside_border.png \) \
	\( -label "Outer Border" /tmp/bleeds/outside_border.png \) \
	+repage -colorspace sRGB -depth 8 -compress RLE '/tmp/bleeds/IM-created-d8.psd'
produced this image: https://www.dropbox.com/s/apv08oy6vh9im ... ted-d8.psd

Re: PSD File Size Too Large

Posted: 2013-07-02T09:08:01-07:00
by snibgo
Indeed. In my simple examples above, r1.psd shows RLE compression. In r2.psd, the first image is RLE compressed; the second shows no compression.