Duplicate images after conversion
Duplicate images after conversion
Hi, I have a problem with imagemagick.
Entering this command:
convert /var/www/html/wp-content/uploads/img/*.* -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 /var/www/html/wp-content/uploads/img/*.*
I have many duplicates of the converted images.
I have no problems when a single file, the problem exists only when I have two or more files.
I have tried many and many files, I tried to insert "-duplicate 0" but the problem is the same.
Screenshots
before converter
after converter
image one.jpg
image two.jpg
image two-0.jpg
image two-1.jpg
image two-2.jpg
How can I solve it?
Thank you.
Marco
Entering this command:
convert /var/www/html/wp-content/uploads/img/*.* -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 /var/www/html/wp-content/uploads/img/*.*
I have many duplicates of the converted images.
I have no problems when a single file, the problem exists only when I have two or more files.
I have tried many and many files, I tried to insert "-duplicate 0" but the problem is the same.
Screenshots
before converter
after converter
image one.jpg
image two.jpg
image two-0.jpg
image two-1.jpg
image two-2.jpg
How can I solve it?
Thank you.
Marco
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Duplicate images after conversion
You cannot use wild cards for the output when you use wild cards for the input with convert. If you want to process a whole folder or set of file, then use mogrify rather than convert. See https://imagemagick.org/Usage/basics/#mogrify It is designed for batch processing. If you do not want to do that, then you will have to write a script loop over each of your input images and use convert to process each one, one at a time.
Re: Duplicate images after conversion
Thank you very much.
Now works.
One last question a bit off topic:
From the terminal I can convert all the files in the folder, if I insert the same code in a .sh file it won't work if I start it from the wordpress plugin. I mean that the whole .sh file is loaded correctly, only the "imagemagick" line is not.
Why? Problem with permissions?
Thanks for your kindness.
Marco
Now works.
One last question a bit off topic:
From the terminal I can convert all the files in the folder, if I insert the same code in a .sh file it won't work if I start it from the wordpress plugin. I mean that the whole .sh file is loaded correctly, only the "imagemagick" line is not.
Why? Problem with permissions?
Thanks for your kindness.
Marco
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Duplicate images after conversion
Sorry, I do not know Wordpress. So I cannot answer your question. Perhaps ask on a Wordpress forum? Just guessing, but perhaps from Wordpress, you might need put the full path to convert. Otherwise, perhaps show us your script.
Re: Duplicate images after conversion
Of course, here is my script.
The "exiftool" command and the "mediafromftpcmd.php" file are executed correctly, unfortunately the "mogrify" (or "convert") no command.
Thanks anyway for your help. You're very kind.
Marco
The "exiftool" command and the "mediafromftpcmd.php" file are executed correctly, unfortunately the "mogrify" (or "convert") no command.
Thanks anyway for your help. You're very kind.
Marco
Code: Select all
#!/bin/sh
exiftool -r -d %Y_%m_%d_%H%M%S.%%e "-filename<filemodifydate" /var/www/html/wp-content/uploads/img/
mogrify /var/www/html/wp-content/uploads/img/*.* -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 /var/www/html/wp-content/uploads/img/*.*
/usr/bin/php /var/www/html/wp-content/plugins/media-from-ftp-add-on-cli/lib/mediafromftpcmd.php
exit
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Duplicate images after conversion
Your mogrify command is wrong. See http://www.imagemagick.org/script/mogrify.php . Mogrify does not take both input and output filenames. It takes one filename (with wildcards) that is for input and also, by default, for output.
snibgo's IM pages: im.snibgo.com
Re: Duplicate images after conversion
the line
exiftool -r -d %Y_%m_%d_%H%M%S.%%e "-filename<filemodifydate" /var/www/html/wp-content/uploads/img/
is managed by Exiftool, not by imagemagick
exiftool -r -d %Y_%m_%d_%H%M%S.%%e "-filename<filemodifydate" /var/www/html/wp-content/uploads/img/
is managed by Exiftool, not by imagemagick
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Duplicate images after conversion
Yes, the "exiftool" line is an exiftool command.
The next line, with "mogrify", is a mogrify command, and it is wrong.
The next line, with "mogrify", is a mogrify command, and it is wrong.
snibgo's IM pages: im.snibgo.com
Re: Duplicate images after conversion
Why is it wrong?
Works properly from "Terminal"
The conversion from cmyk to rgb works, the maximum pixel size works, and I think the quality setting works.
Works properly from "Terminal"
The conversion from cmyk to rgb works, the maximum pixel size works, and I think the quality setting works.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Duplicate images after conversion
You cannot use wild cards for input and output in mogrify. Look at the documentation for the syntax. See my link above.
change directory to inputfolder
mogrify <processing commands only> *
That will get each image from the current directory, process it and write over it with the output. So the * means both input and output. If you want to write to another directory for the output, then create it beforehand and specify it with -path outputdirectory
change directory to inputfolder
mogrify <processing commands only> *
That will get each image from the current directory, process it and write over it with the output. So the * means both input and output. If you want to write to another directory for the output, then create it beforehand and specify it with -path outputdirectory
Re: Duplicate images after conversion
I tried to insert the .sh file with the code
mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680
(also: magick mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 )
in the folder where there are images (without inserting the directory) but it does not work.
I tried my command line from Terminal and it works.
I don't think it's the command line's fault but permission...
You don't think??
mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680
(also: magick mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 )
in the folder where there are images (without inserting the directory) but it does not work.
I tried my command line from Terminal and it works.
I don't think it's the command line's fault but permission...
You don't think??
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Duplicate images after conversion
You have to put * at the end of your mogrify command for it to get the input images from the current directory. It will then write over those images. So be sure you have a backup.
mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 *
Otherwise create a new directory and add -path to the command
mogrify -path newdirectory -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 *
Please read the page on mogrify! https://imagemagick.org/Usage/basics/#mogrify
mogrify -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 *
Otherwise create a new directory and add -path to the command
mogrify -path newdirectory -profile /var/www/html/cmyk.icc -profile /var/www/html/srgb.icc -quality 70 -resize 680 *
Please read the page on mogrify! https://imagemagick.org/Usage/basics/#mogrify