I'm trying to add dev tape and version number in my app following this tutorial, but I'm getting error
"Command PhaseScriptExecution failed with a nonzero exit code"
This error occurs when I execute the command convert betaRibbon.png -resize 120x120 resizedBetaRibbon.png in the Build Phases/Icon Change Script, however when executing the same command through the terminal I do not get any error, understanding that I have the imagemagick and ghostscript are installed correctly. Also I can't execute script files from xcode either. Any ideas?.
I share script code
PATH=${PATH}:/usr/local/bin
IFS=$'\n'
function generateIcon () {
BASE_IMAGE_NAME=$1
TARGET_PATH="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${BASE_IMAGE_NAME}"
BASE_IMAGE_PATH=$(find ${SRCROOT} -name ${BASE_IMAGE_NAME})
WIDTH=$(identify -format %w ${BASE_IMAGE_PATH})
/opt/homebrew/bin/convert betaRibbon.png -resize $WIDTHx$WIDTH resizedRibbon.png
/opt/homebrew/bin/convert ${BASE_IMAGE_PATH} -fill white -font Times-Bold -pointsize 18 -gravity south -annotate 0 "Hello World" - | /opt/homebrew/bin/composite resizedRibbon.png - ${TARGET_PATH}
}
generateIcon "60.png"
generateIcon "120.png"
Related
I am trying to stitch (thousands) of images together via coordinate system using ImageMagick. Because the command is so long, I can't pass it via CLI, but have to save it to a script to load later.
The script looks like this:
script.txt
convert
( foo.png -repage +0+0 )
( bar.png -repage +0+37 )
-layers merge
out.png
I then run magick.exe -script script.txt
But get the following error:
magick.exe: unable to open image 'convert': No such file or directory # error/blob.c/OpenBlob/3457.
magick.exe: no decode delegate for this image format `' # error/constitute.c/ReadImage/512.
The -script command is for ImageMagick 7. You must explicitly -write the output in the script command. See http://www.imagemagick.org/Usage/bugs/IMv7_Scripting.txt
For example, here is a simple script file that I call testscript
#!/path/to/magick -script
rose: -scale 200% -write big_rose.png
To run it you simple use:
magick -script testscript
So for your command, try the script as
#!/path/to/magick -script
( foo.png -repage +0+0 ) ( bar.png -repage +0+37 ) -layers merge -write out.png
(Note I have written it as one line. If you want to use multiple lines, then you must use Windows line ending character, ^, at the end of each line to show continuation to the next line)
Then call it as
magick -script yourscript
I have this code but I would like to edit it so the exported file name is the same as the file name used to make it
mogrify -composite -gravity center ~/Desktop/civmap-client-master/data/watermark.png ~/Desktop/civmap-client-master/data/nowm/*.png ~/Desktop/civmap-client-master/data/wm/*.png
It just throws an error when I used *.png as my exported file name. Please note I have multiple files in the /nowm/ directory. I am using a Mac.
Thanks alot :)
The mogrify command does not accept -composite as an operation as it takes just 2 images. You will have to use a loop:
cd ~/Desktop/where/the/input/images/are
for f in *.png; do
echo $f
convert -gravity center "$f" "~/Desktop/path/to/watermark.png" -composite "~/Desktop/path/to/output/$f"
done
I've been at this all day. I'm trying to upload images to a Mediawiki and this is the error I get when ImageMagick tries to create the thumbnail:
Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' # error/constitute.c/ReadImage/552.
convert: no images defined `/tmp/s3thumb-cripEh' # error/convert.c/ConvertImageCommand/3127.
I setup a debug file for mediawiki and this is what I get in the log:
BitmapHandler::doTransform: creating 112x120 thumbnail at /tmp/s3thumb-cripEh using scaler im
BitmapHandler::doTransform: called wfMkdirParents(/tmp)
BitmapHandler::getMagickVersion: Running convert -version
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' ''\''/usr/local/bin/convert'\'' -version' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
BitmapHandler::transformImageMagick: running ImageMagick: '/usr/local/bin/convert' -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 '/tmp/s3thumb-cripEh' 2>&1
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/local/bin/convert'\'' -quality 80 -background white -define jpeg:size=112x120 '\'''\'' -thumbnail '\''112x120!'\'' -depth 8 -sharpen '\''0x0.4'\'' -rotate -0 '\''/tmp/s3thumb-cripEh'\'' 2>&1' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
[thumbnail] thumbnail failed on ip-10-168-26-167: error 1 "convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' # error/constitute.c/ReadImage/552.
convert: no images defined `/tmp/s3thumb-cripEh' # error/convert.c/ConvertImageCommand/3127." from "'/usr/local/bin/convert' -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 '/tmp/s3thumb-cripEh' 2>&1"
LocalS3File::transform thumb:
LocalS3File::transform thumbTempPath: /tmp/s3thumb-cripEh, dest: wiki-images/thumb/1/19/5ovrDaU.jpg/112px-5ovrDaU.jpg
info:1
LocalS3File::transform return thumb: MediaTransformError Object
(
[htmlMsg] => Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' # error/constitute.c/ReadImage/552.<br />
convert: no images defined `/tmp/s3thumb-cripEh' # error/convert.c/ConvertImageCommand/3127.<br />
[textMsg] => Error creating thumbnail: convert: no decode delegate for this image format `/tmp/magick-11924QG1rRXzT948I' # error/constitute.c/ReadImage/552.<br />
convert: no images defined `/tmp/s3thumb-cripEh' # error/convert.c/ConvertImageCommand/3127.<br />
[width] => 112
[height] => 120
[url] =>
[path] =>
[file] =>
[page] =>
[responsiveUrls] => Array
(
)
[storagePath:protected] =>
)
Tried from the command line, copy pasted the command from the log (but used a test file):
convert -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 'logo.jpg'
but the process hangs. If I run:
sudo convert logo.png -quality 80 -background white -define jpeg:size=112x120 -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 logo.jpg
It works.
If I check DELEGATES, I have:
DELEGATES jng jp2 jpeg png ps tiff xml zlib
I tried increasing the default memory on media wiki to
$wgMaxShellMemory = 202400;
I feel like I've tried anything. Any ideas?
EDIT:
This is what I've discovered so far:
I'm pretty sure the shell wasn't executing the ImageMagick command because of the escaped backslashes in :
wfShellExec: /bin/bash '/var/www/mediawiki-1.21.2/includes/limit.sh' ''\''/usr/local/bin/convert'\'' -version' 'MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=202400; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180'
Those ''\'' are causing the command to not run, and hence the "no decode" error. It can't decode, because the file is not there. I've traced wfShellEec to GlobalFunctions.php. The wfShellExec function is at around line 2778 on my file.
In the if ( php_uname( 's' ) == 'Linux' ) block there is:
escapeshellarg( $cmd )
I removed the escapeshellarg() function and just left the $cmd on its own.
Tried uploading again, the error is gone, the files are created, but now the thumbnail files are 0 bytes.
Any ideas?
In the following, the empty string parameter '' represents what is supposed to be the input image:
convert -quality 80 -background white -define jpeg:size=112x120 '' -thumbnail '112x120!' -depth 8 -sharpen '0x0.4' -rotate -0 'logo.jpg'
When you ran sudo convert logo.png ... from the command line it worked because you had an input image (logo.png), but inside MW the source image parameter was missing. So the problem here is not with convert, ImageMagick naturally cannot convert an image that doesn't exist. The problem is that MW fails to supply the source image file name.
If your case is like mine, the empty '' image source parameter could trace back to permissions in the images directory. Make sure this directory and all its subdirectories are rwx by the server process. Once I opened up everything in this dir to the server, the errors went away and the images and thumbnails appeared perfectly.
I currently run the following command to annotate an image with the variable $handle
When running on a LAMP, everything worked fine and the $handle variable was put into the image. However running on a WAMP, the two apostrophes around the variable are being included into the variable. Which adds a ' to the front and end of the variable. Here is what I'm running. Any ideas why?
exec("C:\ImageMagick\convert $final -font handle_font.ttf -pointsize $font_size -fill
black -annotate $pos_black '$handle' -fill white -annotate $pos_white '$handle'
-flatten $final");
On windows you need to swap the ' for " and in your case escape it with a \
\"$handle\"
Write your code like this and you can then echo out the $cmd and see what it contains:
$cmd = " $final -font handle_font.ttf -pointsize $font_size -fill black -annotate $pos_black \"$handle\" -fill white -annotate $pos_white \"$handle\" -flatten ";
echo $cmd.'<br>';
exec("C:\ImageMagick\convert $cmd $final");
I have a strange probleam with running ImageMagick mogrify on several files. I use conversion string to make several transformation on images, which results in thumbnails. The command with the conversion string runs fine on single file, however when ran on a batch of files, it sometimes fails. Here is the command (windows command line):
"C:\Program Files\ImageMagick-6.3.5-Q16\mogrify" \
-format jpg \
-thumbnail 400x400">" \
-background white \
-gravity center \
-extent 400x400 \
-draw "image src-over 0,0 0,0 '//dell1/Oracle/files/watermark.png'" \
-path \\dell1\Oracle\files\pictures\cj4uoveomiggda97kmqttn0400 \
\\dell1\Oracle\files\pictures\59\59p5huflk2cnv9drf3r1d65ef9_wc \
\\dell1\Oracle\files\pictures\7v\7vi3q26cdidk8bproslhhmlkab_wc \
\\dell1\Oracle\files\pictures\ft\ft0iqkjk08cli8k0iltgmdmfo5_wc
and it fails with message "mogrify: Non-conforming drawing primitive definition `image'."
But I've found out, that this happens only when inserting a wattermark. I've also found out that when I change order of the 3 files which are to be processed, the mogrify runs fine, which is pretty strange. I have no idea why this happens and how to get rid of it.
PS: I execute this command from a java application, so using a batch file with repeated calling of convert command is not acceptable solution for me.
Any clues appreciated, many thanks.
Solved this by installing newer version of ImageMagick :/