Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
2150
views
how to find all pics in a directory and its subdirectories and run a command on them
how to find all images in a directory and its sub-directories, with types ```gif, jpg, jpeg, png, ico```, and run ```mogrify -strip your_filename.jpg``` on them? Can the command ```mogrify -strip``` corrupt an image? Also can the command ```mogrify -strip``` be run on a gif file?
how to find all images in a directory and its sub-directories, with types
, jpg, jpeg, png, ico
, and run -strip your_filename.jpg
on them?
Can the command -strip
corrupt an image?
Also can the command -strip
be run on a gif file?
stacking and exchanging woohoo
(63 rep)
Dec 13, 2022, 10:47 PM
• Last activity: Jun 24, 2025, 02:04 PM
17
votes
8
answers
15965
views
Use mogrify to resize large images while ignoring small ones
I'm running the following command: mogrify -resize '400x400>' *.png According to the [docs][1], the "widthxheight>" geometry (with `>` at the end) "Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s)." I expect the images with width/height less than 400x4...
I'm running the following command:
mogrify -resize '400x400>' *.png
According to the docs , the "widthxheight>" geometry (with
>
at the end) "Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s)."
I expect the images with width/height less than 400x400 to be untouched, but mogrify rewrites the file for no reason―the modification date and file size are changed.
Is there a way to make it actually just leave the smaller images alone? I'd like to avoid several thousand unnecessary write operations.
Mike
(325 rep)
May 18, 2012, 02:38 PM
• Last activity: Aug 5, 2024, 05:05 PM
2
votes
3
answers
3922
views
Preserve image's modification time with mogrify/imagemagick
I have a huge collection of family photos which I don't really need full resolution of. I want to use mogrify but I tried it on a sample set of images and it seems that it sets modification time of files to current time. Is there any way to preserve modification/create time of original image (for bo...
I have a huge collection of family photos which I don't really need full resolution of. I want to use mogrify but I tried it on a sample set of images and it seems that it sets modification time of files to current time. Is there any way to preserve modification/create time of original image (for both EXIF data and linux's native file modification times which you can view using
stat
)?
Deepak Mittal
(1554 rep)
Mar 17, 2018, 09:32 PM
• Last activity: Oct 11, 2023, 10:58 AM
-1
votes
1
answers
183
views
Using mogrify - case insensitive file search
I use mogrify as such: `mogrify -monitor -quality 80 -resize 1200 *JPG` However, this only matches files ending in .JPG. How do I include .jpg files at the same time (in other words, how to make the pattern case-insensitive)?
I use mogrify as such:
mogrify -monitor -quality 80 -resize 1200 *JPG
However, this only matches files ending in .JPG. How do I include .jpg files at the same time (in other words, how to make the pattern case-insensitive)?
anon
Jan 12, 2022, 08:43 PM
• Last activity: Jan 12, 2022, 09:44 PM
0
votes
1
answers
560
views
How to rotate all images 90 degrees in a directory and all sub-directories (using mogrify)?
I'm attempting to do as my question title indicates, here is my best attempt so far: find . -name '*.jpeg' -exec mogrify -rotate 90 '*.jpeg' {} + This seems to rotate the images in the current directory and sub-directories 90 degrees clockwise (put a negative sign in front of the 90 and it will do c...
I'm attempting to do as my question title indicates, here is my best attempt so far:
find . -name '*.jpeg' -exec mogrify -rotate 90 '*.jpeg' {} +
This seems to rotate the images in the current directory and sub-directories 90 degrees clockwise (put a negative sign in front of the 90 and it will do counter-clockwise), but I get this error:
mogrify-im6.q16: unable to open image `*.jpeg': No such file or directory @ error/blob.c/OpenBlob/2874.
I'm not sure if this matters but it certainly isn't reassuring. I'm aware that to list all
.jpeg
s within a directory and sub-directories is:
find . -name '*.jpeg'
and the basic syntax of exec
is:
-exec command {} +
so the above apparently isn't quite right, can anybody tell me what I'm doing wrong? I'm using Ubuntu 20.04 if that matters.
cdahms
(131 rep)
Oct 29, 2021, 08:10 PM
• Last activity: Oct 29, 2021, 08:15 PM
1
votes
1
answers
195
views
Can't rm formats after conversion
How can I fix the following command, so that all files with the format specified with the rm command are deleted? #!/bin/bash mogrify -verbose -format webp -quality 70 *.jpg *.jpeg *.JPEG *.JPG *.png *.PNG && rm --verbose *.jpg *.jpeg *.JPEG *.JPG *.png *.PNG $SHELL The command successfully converts...
How can I fix the following command, so that all files with the format specified with the rm command are deleted?
#!/bin/bash
mogrify -verbose -format webp -quality 70 *.jpg *.jpeg *.JPEG *.JPG *.png *.PNG && rm --verbose *.jpg *.jpeg *.JPEG *.JPG *.png *.PNG
$SHELL
The command successfully converts the images to webp, but rm doesn't delete any of the original files.
I get the following errors after converting to webp:
mogrify-im6.q16: unable to open image `*.jpeg': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.JPG': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.JPG': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.png': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.png': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.PNG': No such file or directory @ error/blob.c/OpenBlob/2874.
mogrify-im6.q16: unable to open image `*.PNG': No such file or directory @ error/blob.c/OpenBlob/2874.
whitewings
(2527 rep)
Nov 26, 2020, 10:41 PM
• Last activity: Nov 26, 2020, 11:35 PM
1
votes
1
answers
514
views
How can I use mogrify to target a specific pixel value of the largest dimension so if vertical set height to 'x' or if horizontal, set width to 'x'
So I've successfully used `$ mogrify -resize 3000` to accomplish setting dimension on batches of images. What this yields me is exactly that- a group of images that have a 3000px width. The issue lies in vertical images that now have a vertical value larger than I would like. My question is: Is ther...
So I've successfully used
$ mogrify -resize 3000
to accomplish setting dimension on batches of images. What this yields me is exactly that- a group of images that have a 3000px width. The issue lies in vertical images that now have a vertical value larger than I would like.
My question is: Is there a solution that assesses the largest value (height or width) and then assigns the resize to that dimension.
Thanks in advance!
visyoual
(167 rep)
Jun 3, 2020, 03:04 PM
• Last activity: Jun 3, 2020, 03:58 PM
0
votes
1
answers
738
views
Find gif/jpeg files with png extension and convert to png
First command find and list jpeg/gif files with png extension. Second command convert a file to png. 1. `find . -type f -name "*.png" | xargs -L 1 -I{} file -i {} | grep -v 'image/png; charset=binary$'` 2. `find . -name "*.jpg" -exec mogrify -format png {} \;` **I to combine these two commands.**
First command find and list jpeg/gif files with png extension.
Second command convert a file to png.
1.
find . -type f -name "*.png" | xargs -L 1 -I{} file -i {} | grep -v 'image/png; charset=binary$'
2. find . -name "*.jpg" -exec mogrify -format png {} \;
**I to combine these two commands.**
Dhillon
(37 rep)
Sep 11, 2017, 04:48 PM
• Last activity: Nov 16, 2018, 08:04 PM
3
votes
2
answers
545
views
Loop through files and convert BMP files to JPG
I have a folder of images. All have the JPG extension but when running `file` against a few, they're coming back as bitmap e.g. 25818.jpg: PC bitmap, Windows 3.x format, 357 x 500 x 24 My question is how would I loop through all the images, check whether it's a bitmap file and then convert it to a J...
I have a folder of images. All have the JPG extension but when running
file
against a few, they're coming back as bitmap e.g.
25818.jpg: PC bitmap, Windows 3.x format, 357 x 500 x 24
My question is how would I loop through all the images, check whether it's a bitmap file and then convert it to a JPG?
The command I'd use in a single case would be the following but not sure how I'd do the checks and loop through the files
mogrify -format jpg 25818.jpg
Thanks
pee2pee
(193 rep)
Apr 17, 2017, 08:09 PM
• Last activity: Aug 30, 2017, 09:41 PM
4
votes
0
answers
942
views
Convert NEF to JPG with optimal brightness
There are multiple tools for converting Nikon raw images (.NEF) to JPEG, as well as there are multiple discussions on this topic (e.g. https://unix.stackexchange.com/questions/226900/converting-nef-to-jpg/283791). My question regards optimal settings for nice output images. I have a bunch of NEF fil...
There are multiple tools for converting Nikon raw images (.NEF) to JPEG, as well as there are multiple discussions on this topic (e.g. https://unix.stackexchange.com/questions/226900/converting-nef-to-jpg/283791) . My question regards optimal settings for nice output images.
I have a bunch of NEF files. When I open them in Gwenview (4.14.0 pre), they look great. In that application, I can save them as JPEGs individually. The output files look the same (i.e. fine), but it does not seem to provide a way to do it in batch. Saving the files one by one is nonsense.
So I'd like to use a bash tool. Anyway, if I convert the images with
mogrify -format JPG *.NEF
or convert DSC0001.NEF DSC0001.JPG
(see the aforementioned discussion), the output files are pretty dark. **I wonder what parameters should be used to achieve the same (or at least similar) results, compared to Gwenview.** (Not really sure how Gwenview detects the "optimal" settings - NEF metadata? Math?)
yman
(181 rep)
Nov 2, 2016, 07:56 PM
2
votes
2
answers
677
views
How do I use mogrify convert only on files with a certain creation date?
I'm creating an animated gif using mogrify's `convert`. However, at the moment I run in on a folder with dozens of images in it, and I just instruct it to use all of the images it finds. However, I'd like it to only use files that were created on a particular date. Can I do such a thing? Current com...
I'm creating an animated gif using mogrify's
convert
. However, at the moment I run in on a folder with dozens of images in it, and I just instruct it to use all of the images it finds. However, I'd like it to only use files that were created on a particular date. Can I do such a thing?
Current command used:
convert -delay 10 -loop 0 images/* animation.gif
All my filenames are timestamps so alternatively I'd like to be able to specify a range, something like:
convert -delay 10 -loop 0 --start="images/147615000.jpg" --end="images/1476162527.jpg" animation.gif
I've tried the convert
man pages but no luck. Is any of this possible?
please delete me
(2659 rep)
Oct 11, 2016, 05:12 AM
• Last activity: Oct 11, 2016, 11:07 PM
1
votes
2
answers
709
views
Find files with 32 character long recursively in a directory and apply a command
I have folders and files looks likes this: /thumbs/6b0/6b029aab9ca00329cd28fd792ecf90a.jpg /thumbs/6b0/6b029aab9ca00329cd28fd792ecf90a-s.jpg /thumbs/d11/d11e15a72e20e14c45bd2769d763126d.jpg /thumbs/d11/d11e15a72e20e14c45bd2769d763126d-s.jpg And I want to apply following command to the files not have...
I have folders and files looks likes this:
/thumbs/6b0/6b029aab9ca00329cd28fd792ecf90a.jpg
/thumbs/6b0/6b029aab9ca00329cd28fd792ecf90a-s.jpg
/thumbs/d11/d11e15a72e20e14c45bd2769d763126d.jpg
/thumbs/d11/d11e15a72e20e14c45bd2769d763126d-s.jpg
And I want to apply following command to the files not have -s in their names in all sub directories in thumbs folder.
mogrify -resize 50% -quality 85 -strip filename.jpg
I have look around find and grep but couldn't figure out how can I do this.
Any help appreciated.
user260223
(13 rep)
Aug 16, 2016, 02:27 AM
• Last activity: Aug 16, 2016, 06:51 AM
0
votes
1
answers
1072
views
Resizing/Processing only images in folder larger than specified height?
I have a folder with JPG images, some of which have a height dimension larger than 1900 pixels. I need a command that will ignore the images with a height dimension lower than 1900 pixels, while resizing only images with a greater height. This command does the resizing job, but in the process it sti...
I have a folder with JPG images, some of which have a height dimension larger than 1900 pixels. I need a command that will ignore the images with a height dimension lower than 1900 pixels, while resizing only images with a greater height.
This command does the resizing job, but in the process it still opens and re-saves the images it doesn't resize, which eats up HD and CPU bandwidth:
mogrify -resize 'x1900>' *.jpg
Is there a better command, that will ignore the images that fall below the pixel threshold?
The question is different from the question here: https://unix.stackexchange.com/questions/38943/use-mogrify-to-resize-large-files-while-ignoring-small-ones
I want the command to determine which JPGs are larger than a certain height, taking the width out of the equation.
whitewings
(2527 rep)
Apr 26, 2015, 10:25 PM
• Last activity: Apr 26, 2015, 11:25 PM
0
votes
1
answers
591
views
Imagemagick mogrify with shadow geometry
How can I specify the size of a shadow with imagemagick? This command works: montage foo.jpg bar.jpg foobar.jpg -background lightgray -geometry 1031x1642+57+57 -shadow -monitor -tile 3x1 out.png While this one gives an error: montage foo.jpg bar.jpg foobar.jpg -background lightgray -geometry 1031x16...
How can I specify the size of a shadow with imagemagick?
This command works:
montage foo.jpg bar.jpg foobar.jpg -background lightgray -geometry 1031x1642+57+57 -shadow -monitor -tile 3x1 out.png
While this one gives an error:
montage foo.jpg bar.jpg foobar.jpg -background lightgray -geometry 1031x1642+57+57 -shadow 100x10+200+200 -monitor -tile 3x1 out.png
The error being:
> montage: unable to open image `100x10+200+200': No such file or
> directory @ error/blob.c/OpenBlob/2675. montage: no decode delegate
> for this image format `' @ error/constitute.c/ReadImage/501.
Jan Rüegg
(151 rep)
Mar 27, 2015, 10:36 PM
• Last activity: Mar 28, 2015, 08:17 AM
1
votes
1
answers
1740
views
How to create a timed video from still images with specific time between each image?
I want to create a video from still images. My images are: - 1.jpg - 2.jpg - 3.jpg - 4.jpg - 5.jpg - 6.jpg - 7.jpg - 8.jpg - 9.jpg Each of them I want to show for a specific duration, between 1-10 seconds: - 1.jpg: 2 seconds - 2.jpg: 6 seconds - 3.jpg: 10 seconds - 4.jpg: 1 second etc. Between the i...
I want to create a video from still images. My images are:
- 1.jpg
- 2.jpg
- 3.jpg
- 4.jpg
- 5.jpg
- 6.jpg
- 7.jpg
- 8.jpg
- 9.jpg
Each of them I want to show for a specific duration, between 1-10 seconds:
- 1.jpg: 2 seconds
- 2.jpg: 6 seconds
- 3.jpg: 10 seconds
- 4.jpg: 1 second
etc.
Between the images I want to gradually fade out the old image and fade in the new image.
I have a feeling this can all be done with
convert
and ffmpeg
. However, the problem is with having the different duration between each image. This page helps a lot, but I can't figure out how to time things between images. Any ideas?
user
(1075 rep)
Oct 5, 2014, 05:09 PM
• Last activity: Oct 6, 2014, 04:39 AM
2
votes
2
answers
6295
views
Convert a lot of .tif files using imagemagick's mogrify command
I have a lot of tif images in a directory. So I try to convert them into jpg format. I use this command : `mogrify -format jpg *.tif` But I get an error... an error for each image in fact: mogrify: 2281.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFF...
I have a lot of tif images in a directory. So I try to convert them into jpg format.
I use this command :
mogrify -format jpg *.tif
But I get an error... an error for each image in fact:
mogrify: 2281.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/746.
Maybe I am doing something wrong... Does anyone have an idea?
Raphaël
(543 rep)
Jan 20, 2012, 10:06 AM
• Last activity: Jan 20, 2012, 04:18 PM
Showing page 1 of 16 total questions