Auto generate renditions .jpg, .psd 'unable to open image' error

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
ChristianJP
Posts: 3
Joined: 2016-11-27T11:09:51-07:00
Authentication code: 1151
Contact:

Auto generate renditions .jpg, .psd 'unable to open image' error

Post by ChristianJP »

Hello!
I am trying to write a script to automatically generate renditions for .tif, .jpg and .psd files.
(I'm on ImageMagick 7.0.2-1 Q16 x64 2016-06-23)

Right now, my script says:


@echo off

set ORIGINAL_FOLDER=.\original-assets
set RENDITION_FOLDER=.\renditions

for /f %%A in ('dir /B %ORIGINAL_FOLDER%') DO (
echo Generating Renditions for %%A...
::* Generate High Res JPEG (300dpi) CMYK
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 300 -colorspace CMYK -gravity center -adjoin %RENDITION_FOLDER%/300CMYK/%%A_300CMYK.jpg

::* Generate High Res JPEG (300dpi) RGB
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 300 -colorspace sRGB -gravity center %RENDITION_FOLDER%/300RGB/%%A_300RGB.jpg

::* Generate Low res jpeg (150 dpi) RGB
convert %ORIGINAL_FOLDER%/%%A -density 150 -define jpeg -colorspace sRGB -gravity center %RENDITION_FOLDER%/150/%%A_150.jpg

::* Generate Low res jpeg (72 dpi) RGB
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 72 -colorspace sRGB -gravity center %RENDITION_FOLDER%/72/%%A_72.jpg

The script runs successfully on the .tif file, but I get the following error for the .jpg and .psd:


convert: unable to open image '.\original-assets/Collect': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/300CMYK/Collect_300CMYK.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Collect': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/300RGB/Collect_300RGB.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Collect': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/150/Collect_150.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Collect': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/72/Collect_72.jpg' @ error/convert.c/ConvertImageCommand/3235.

Generating Renditions for Polichrome_...
convert: unable to open image '.\original-assets/Polichrome_': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/300CMYK/Polichrome__300CMYK.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Polichrome_': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/300RGB/Polichrome__300RGB.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Polichrome_': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/150/Polichrome__150.jpg' @ error/convert.c/ConvertImageCommand/3235.
convert: unable to open image '.\original-assets/Polichrome_': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508.
convert: no images defined `.\renditions/72/Polichrome__72.jpg' @ error/convert.c/ConvertImageCommand/3235.

Why did it work for the .tif but not the others? What do I need to add to my script to get it to work? What does the error mean?
I am completely new to IM and have zero coding experience.

Any help is much appreciated!!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Contact:

Re: Auto generate renditions .jpg, .psd 'unable to open image' error

Post by snibgo »

Do a directory listing. Do you actually have a file called ".\original-assets/Collect"? I suspect you don't, but do have a file with a space in the name, something like ".\original-assets/Collect something else.jpg". If so, then you should put quotes around filenames in your convert.
snibgo's IM pages: im.snibgo.com
ChristianJP
Posts: 3
Joined: 2016-11-27T11:09:51-07:00
Authentication code: 1151
Contact:

Re: Auto generate renditions .jpg, .psd 'unable to open image' error

Post by ChristianJP »

snibgo wrote:Do a directory listing. Do you actually have a file called ".\original-assets/Collect"? I suspect you don't, but do have a file with a space in the name, something like ".\original-assets/Collect something else.jpg". If so, then you should put quotes around filenames in your convert.
It was the filename which had spaces. It works now! Thank you!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests