0

I am using an animation software that outputs the animation as PNG sequences labeled filename-001.png, filename-002.png etc. I'd like to use imagemagick's convert to compile a PSD so I can edit it fast in Photoshop.

I need the Windows batch file to get all the png files from the folder the batch file resides in (or alternatively drag and drop the first image in the sequence or drag and drop the folder) and convert them in a layered PSD file.

The label ideally should be the filename part (e.g. for layer 2 = "filename-002")

Currently my batch is as follows:

convert
( -page +0+0 -label "label1" "filename-001.png"[0] -background none -mosaic -set colorspace RGB )
( -page +0+0 -label "label2" "filename-002.png"[0] -background none -mosaic -set colorspace RGB )
( -page +0+0 -label "label3" "filename-003.png"[0] -background none -mosaic -set colorspace RGB )
( -page +0+0 -label "label4" "filename-004.png"[0] -background none -mosaic -set colorspace RGB )
( -clone 0--1 -background none -mosaic ) -reverse "out.psd"

This of course converts the png images that I input manually, I need to make this more automatic.

Also finally, the resulting PSD has its layers opacity-locked, I'd like them not to be locked so I can edit the PSD faster in Photoshop.

9
  • Which specific aspect of that is troubling you? Dec 18, 2015 at 14:56
  • do you know about %1% in .bat scripting? Otherwise it looks like you're good to make your animation. Good luck.
    – shellter
    Dec 18, 2015 at 15:11
  • So that is your batch-file? I have never seen bat code that looks like that.
    – Squashman
    Dec 18, 2015 at 15:15
  • The code you posted is not a Windows batch-file (with an extension .bat or .cmd), is it?
    – aschipfl
    Dec 18, 2015 at 15:29
  • I think this is 1 command broken into multiple lines, isn't it? Dec 18, 2015 at 16:07

1 Answer 1

3

You could try this, although I can't test it because I don't have imagemagic myself:

@echo off
setlocal enabledelayedexpansion
set number=1
set "command=convert"
for %%f in (*.png) do (
  set "command=!command! ^( -page +0+0 -label ^"label!number!^" ^"%%~nxf^"[0] -background none -mosaic -set colorspace RGB ^)"
  set /a number=!number!+1
)
set "command=%command% ^( -clone 0--1 -background none -mosaic ^) -reverse ^"out.psd^""
%command%
pause

I think the opacity problem can be found here

7
  • This worked fine thanks, though the layers do not get the filename part but I am certain I can get that with %~nxf or something. Also the layers are still opacity-locked but after some searching, I think this could be a bug/feature(?) of imagemagick.
    – user780756
    Dec 18, 2015 at 16:36
  • What do you mean the layers do not get the filename part? Do you mean the label name? Seeing as you called your labels label1..label4 I though you numerically wanted to name them. Dec 18, 2015 at 16:41
  • are the numbers always the last 3 characters of the filename? then you can use %%~nf and substring. Dec 18, 2015 at 16:44
  • 1
    By the way, if my question solved your problem you should click the check to the left of it to mark it as correct. If it didn't feel free to leave a comment saying what's going wrong and I'll try to help. Dec 18, 2015 at 16:48
  • @user780756, when you provide obfuscated examples, you get obfuscated code.
    – Squashman
    Dec 18, 2015 at 17:05

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.