Page 1 of 1
mogrify batch @textfile.txt not working
Posted: 2011-01-27T10:32:51-07:00
by surf_uk
I have been using the following command successfully in the past but now it has stopped working:
Code: Select all
mogrify -crop 300x300+0+0 -gravity Center @picsToConvert.txt
The picsToConvert.txt file contains:
Code: Select all
/media/media/0004_x264m_libschro/results/original/crop/00100.png
/media/media/0004_x264m_libschro/results/original/crop/00200.png
The error is:
Code: Select all
mogrify: unrecognized gravity type `magick' @ error/mogrify.c/MogrifyImageCommand/5057.
The version is from Ubuntu repository:
Code: Select all
Version: ImageMagick 6.6.2-6 2010-12-02 Q16 http://www.imagemagick.org
It's as though the @ symbol is being read as part of the gravity option, or whatever option preceeds the @.
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T10:46:36-07:00
by fmw42
Mogrify works on directories and as far as I know does not work from a text file list of images.
Convert will work with a text file as input. The output image could be some multiframe format or separate images.
This work:
convert logo.png zelda3.png lena.png -gravity center -crop 100x100+0+0 +repage tmp.tiff (gives a multiframe image)
or
convert logo.png zelda3.png lena.png -gravity center -crop 100x100+0+0 +repage tmp_%d.png (gives multiple images)
And if I put all 3 image names in a text file, then this works.
convert @tmp.txt -gravity center -crop 100x100+0+0 +repage tmp2_%d.png
Also you could write a script that will read the images from the text file and loop over a convert to crop the image and write an appropriate output for each image.
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:09:23-07:00
by surf_uk
Well this used to work. As I understood it, mogrify modifies an image (i.e. crop me.jpg) whereas convert requires both an input and output image file (i.e. convert me.jpg to me.png). Is it possible to do this with convert without generating another image file which I would have to find and remove?
Because the images I need to crop are in arbitrary locations I used the text file with image paths to achieve batch job processing. If I swap the arguments around to:
Code: Select all
mogrify @picsToConvert.txt -crop 300x300+0+0 -gravity Center
This works and I can see that mogrify is touching each image and the Gnome folder thumbnail refreshes but it does not crop anything. Its as if the commands need to preceed the files.
Any ideas?
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:17:16-07:00
by magick
Try the -crop option right after the 'mogrify' keyword and before the file path filename.
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:27:47-07:00
by surf_uk
I'm afraid this doesn't work either...
Code: Select all
ross@ross-encoder:/media/media/240subset/test$ mogrify -crop 30x30+0+0 @pics.txt -gravity Center
mogrify: invalid argument for option `magick': -crop @ error/mogrify.c/MogrifyImageCommand/4546.
ross@ross-encoder:/media/media/240subset/test$
ross@ross-encoder:/media/media/240subset/test$
ross@ross-encoder:/media/media/240subset/test$ mogrify -crop @pics.txt 30x30+0+0 -gravity Center
mogrify: unable to open image `30x30+0+0': @ error/blob.c/OpenBlob/2498.
mogrify: no decode delegate for this image format `30x30+0+0' @ error/constitute.c/ReadImage/532.
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:32:14-07:00
by fmw42
try putting the list of images last in the mogrify command
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:44:05-07:00
by surf_uk
Isn't that what I tried in my original post?
Edit... sorry yes this works:
Code: Select all
ross@ross-encoder:/media/media/240subset/test$ mogrify -crop 30x30+0+0 -gravity Center 00001.png 00002.png
ross@ross-encoder:/media/media/240subset/test$
But how could put the list of images in at the end, from a text file?
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T12:47:28-07:00
by magick
We're using ImageMagick 6.6.7-3. This command worked as expected without complaint;
- mogrify -crop 100x100+100+100 -gravity center @paths.txt
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-27T13:11:57-07:00
by surf_uk
Maybe it's a bug which has been fixed. Can you ask Canonical/Ubuntu to update their version ?
I have found a work around using this script:
http://bash.cyberciti.biz/file-manageme ... e-by-line/
and adding this line to the processLine() function:
Code: Select all
echo "mogrify -crop 300x300+0+0 -gravity Center $line"
mogrify -crop 300x300+0+0 -gravity Center $line
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-30T23:02:48-07:00
by anthony
For other methods of doing a file list see
http://www.imagemagick.org/Usage/basics/#mogrify_not
xargs is good method.
cat list_of_files.txt | xargs -i mogrify .... '{}'
parallel is a xargs equivelent that will use multiple cores to process files in parellel though as IM is already multi-threaded that may not always be a good thing.
Re: mogrify batch @textfile.txt not working
Posted: 2011-01-31T01:38:23-07:00
by surf_uk
Thanks that's a very elegant batch process method and a brilliant resource link!