Reputation: 583
I have a .sh in osx mac to generate icons context in app, but when i run script i get a message
convert: unable to open image `c.png': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: unable to open file `c.png' @ error/png.c/ReadPNGImage/3917.
convert: no images defined `mipmap-mdpi/c.png' @ error/convert.c/ConvertImageCommand/3210.
and file c.png stay in folder
read original
read nombre_resultante
read size
Resize () {
if [ "$size" == "1" ]; then
SIZE_MDPI="48x48"
SIZE_HDPI="72x72"
SIZE_XHDPI="96x96"
SIZE_XXHDPI="144x144"
SIZE_XXXHDPI="192x192"
elif [ "$size" == "2" ]; then
SIZE_MDPI="24x24"
SIZE_HDPI="36x36"
SIZE_XHDPI="48x48"
SIZE_XXHDPI="72x72"
SIZE_XXXHDPI="96x96"
fi
rm -rf mipmap-mdpi/*
rm -rf mipmap-hdpi/*
rm -rf mipmap-xhdpi/*
rm -rf mipmap-xxhdpi/*
rm -rf mipmap-xxxhdpi/*
convert $original -resize "$SIZE_MDPI" mipmap-mdpi/$nombre_resultante
convert $original -resize "$SIZE_HDPI" mipmap-hdpi/$nombre_resultante
convert $original -resize "$SIZE_XHDPI" mipmap-xhdpi/$nombre_resultante
convert $original -resize "$SIZE_XXHDPI" mipmap-xxhdpi/$nombre_resultante
convert $original -resize "$SIZE_XXXHDPI" mipmap-xxxhdpi/$nombre_resultante
}
Resize $size
Upvotes: 1
Views: 191
Reputation: 124648
The error message means that the file c.png
doesn't exist. I can reproduce your error message with a non-existent file:
$ convert nonexistent.png -resize 48x48 a/b/whatever.png convert: unable to open image `nonexistent.png': No such file or directory @ error/blob.c/OpenBlob/2702. convert: unable to open file `nonexistent.png' @ error/png.c/ReadPNGImage/3913. convert: no images defined `a/b/whatever.png' @ error/convert.c/ConvertImageCommand/3241.
Probably you are in the wrong directory when you run the script.
cd
to the correct directory where the file exists, and also where the sub-directories mipmap-*dpi
exist.
You can add a check before calling the resizing function like this:
if [ ! -f "$original" ]; then
echo fatal: file does not exist: $original
exit 1
fi
Upvotes: 2