psd to jpg conversion question

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?".
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

psd to jpg conversion question

Post by jamtat »

I note that IM allows conversion of psd to jpg using the mogrify command. I ran that command on a group of psd files and ended up with about 3 times as many jpg's as there were original psd's. I suppose that's because psd's store layers or something like that, and that the layers get extracted as separate files in the conversion process? Is there any switch that will cause IM to produce but a single jpg from each psd? Perhaps the -flatten opton or something similar?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: psd to jpg conversion question

Post by Bonzo »

Try input.psd[0]
The layers start at 0 not 1 and layer 0 should be all the layers in one.
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Thanks for your reply, Bonzo. So if the command I'm running is

Code: Select all

 mogrify -format jpg -path /path/to/converted/images/ -resize 1280x1024 /path/to/psd/files/*.psd
where, exactly, does the input.psd[0] bit get inserted?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: psd to jpg conversion question

Post by Bonzo »

I would guess:

Code: Select all

mogrify -format jpg -path /path/to/converted/images/ -resize 1280x1024 /path/to/psd/files/*.psd[0]
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Unfortunately, running that command did not result in the successful conversion of any psd's, Bonzo. I'll try the -flatten switch and see if that reduces the number of jpg's that get produced during conversion.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: psd to jpg conversion question

Post by dlemstra »

Can you try if adding the following:

Code: Select all

mogrify -format jpg -path /path/to/converted/images/ -scene 0 -resize 1280x1024 /path/to/psd/files/*.psd
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Thanks for your input, diemstra. I actually tried the -flatten switch first, which gave better results than either the initial command I was attempting or the one that Bonzo suggested: only one of each .psd got converted to .jpg instead of 3 or so jpg's being produced for each .psd (or none at all). That is, until I got near the end of the group of files being converted.

The process would not work on the last 5 files and threw out an error message I've seen and asked about in another thread: mogrify: unable to extent pixel cache `No such file or directory' @ fatal/cache.c/CacheSignalHandler/3359 (I asked about that error message in the recent "Some issues with creating contact sheets from tif" thread). I was able discretely to convert four of those last five files, one at a time. But the final file, which is a 238 MB .psd file, will simply not convert using any command I've tried so far. Each time, the mogrify: unable to extent pixel cache `No such file or directory' @ fatal/cache.c/CacheSignalHandler/3359 is the only result, after the computer churns on for awhile, using a lot of CPU cycles.

That error message, which was preventing me from converting tif's, is now preventing me from converting certain psd's as well. Any idea what might be going on here? I'm not an IM power-user by any stretch, but it's always worked so well for me in past image-manipulation tasks.
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Here's the output of -debug cache when I try to convert this file, in case it will be of any help:
2014-02-22T16:28:57-06:00 0:01.790 0.010u 6.8.8 Cache mogrify[1154]: cache.c/DestroyPixelCache/961/Cache
destroy
2014-02-22T16:28:57-06:00 0:01.800 0.010u 6.8.8 Cache mogrify[1154]: cache.c/DestroyPixelCache/961/Cache
destroy
2014-02-22T16:28:57-06:00 0:01.810 0.010u 6.8.8 Cache mogrify[1154]: cache.c/OpenPixelCache/3600/Cache
open path/to/psds/Untitled-.psd[0] (Heap Memory, 12288x9216 1.6875GiB)
2014-02-22T16:29:25-06:00 0:29.590 4.480u 6.8.8 Cache mogrify[1154]: cache.c/SetPixelCacheExtent/3469/Cache
extend path/to/psds/Untitled-.psd[0] (/tmp/magick-11543FzvRPvABbmI[4], disk, 1.8119GB)
2014-02-22T16:29:25-06:00 0:29.710 4.480u 6.8.8 Cache mogrify[1154]: cache.c/OpenPixelCache/3743/Cache
open path/to/psds/Untitled-.psd[0] (/tmp/magick-11543FzvRPvABbmI[-1], Map, 12288x9216 1.6875GiB)
mogrify: unable to extent pixel cache `No such file or directory' @ fatal/cache.c/CacheSignalHandler/3359.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: psd to jpg conversion question

Post by dlemstra »

What is the available diskspace on /tmp?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Here's the output of df -h (anonymized):
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 292G 47G 231G 17% /
dev 864M 0 864M 0% /dev
run 867M 496K 867M 1% /run
tmpfs 867M 0 867M 0% /dev/shm
tmpfs 867M 0 867M 0% /sys/fs/cgroup
tmpfs 867M 8.0K 867M 1% /tmp
/dev/sdb1 466G 14G 453G 3% /home/user/mnt/usb-drv
So, between the two disks I've got almost 700 GB free. Now that I look at this more closely, though, it appears my OS (Arch) is creating a special mount point and file system for /tmp that's less than 1 GB. Maybe that's the issue. I guess I might need to stipulate a directory on the hard drive as the cache, then? Should that be a loop file? Or just a regular old directory? Thanks for your question, diemstra.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: psd to jpg conversion question

Post by dlemstra »

You should create a directory '/magick-tmp' (or any other name you like) and do the following before running convert:
setenv MAGICK_TMPDIR /magick-tmp
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

I tried the -define registry:temporary-path= switch, stipulating a directory I'd created under my home directory for that purpose. But I still get the mogrify: unable to extent pixel cache `No such file or directory' @ fatal/cache.c/CacheSignalHandler/3359. error when trying to convert this file. Not sure what else I can do to resolve or diagnose this issue.
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

dlemstra wrote:You should create a directory '/magick-tmp' (or any other name you like) and do the following before running convert:
setenv MAGICK_TMPDIR /magick-tmp
Ok. Thanks for the suggestion. I'll try that now.
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

I ran set env MAGICK_TMPDIR /path/to/tmp-dir/in/home before trying the conversion just now. But I still get the mogrify: unable to extent pixel cache `No such file or directory' @ fatal/cache.c/CacheSignalHandler/3359 error. Any other suggestions?
jamtat
Posts: 47
Joined: 2010-05-10T16:51:23-07:00
Authentication code: 8675308

Re: psd to jpg conversion question

Post by jamtat »

Ok. Turns out I needed the bash equivalent of setenv--export MAGICK_TMPDIR=/home/path/to/created-tmp. The process is still churning away and hasn't exited with the error yet. So this may well be the resolution I was looking for. Thanks
Post Reply