Modify images based on date range?
-
- Posts: 3
- Joined: 2016-11-16T07:51:13-07:00
- Authentication code: 1151
Modify images based on date range?
Hello, I'm a systems administrator for a contracting company and we've started noticing that our file server is getting way too full way too quickly, and I've determined it's due to the sheer number of images we have saved on the server (we have consultants out on the field that send in photos they take of sites that we save onto the server). Since we'd rather not keep buying hard drives we're looking into batch processing these images to reduce their size (because ~250 images per day at ~8 MB per image adds up pretty quickly). For this, I've found that ImageMagick seems like the best option since it is pretty quick and the command line makes it easy to process subdirectories without having to actually go to each individual folder.
My plan is to use ImageMagick to process the images we already have, then set up a monthly script that forces ImageMagick to process images that were submitted during that month (i.e. all October images would be processed on the 31st, etc.), and therein lies my concern. Is there an option within ImageMagick to modify images in a given date range?
Thanks!
My plan is to use ImageMagick to process the images we already have, then set up a monthly script that forces ImageMagick to process images that were submitted during that month (i.e. all October images would be processed on the 31st, etc.), and therein lies my concern. Is there an option within ImageMagick to modify images in a given date range?
Thanks!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Modify images based on date range?
No. IM can extract dates from various metadata fields, but can't use that to decide whether to process files. I'd do that with a shell script.benchmarkjoshw wrote:Is there an option within ImageMagick to modify images in a given date range?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify images based on date range?
Unix systems have a cron command that will allow you to schedule the launch of a shell script to do the processing. I do not know about Windows servers.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Modify images based on date range?
The Windows equivalent to "cron" is "schtasks".
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2016-11-16T07:51:13-07:00
- Authentication code: 1151
Re: Modify images based on date range?
Alright, well with what little Powershell knowledge I have I've cobbled together a script to supposedly do what I want, but I'm having a bit of issue with it in that when I run it it doesn't actually do anything to the photos in my directory. Would it be possible to get more experienced eyes on it to see where it's getting messed up? I understand if this is a question best left to other forums, but since it only seems to be the ImageMagick part specifically I figure I might as well try here first.
Code: Select all
$path = "C:\Users\Me\Desktop\TestPhotos"
# Modify files older than the limit.
Get-ChildItem -Path $path -Recurse -Include .jpg | Where-Object {$_.LastWriteTime -gt (Get-Date) -and $_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Foreach {magick mogrify $path -resize 50%> *.jpg}
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Modify images based on date range?
$path is "C:\Users\Me\Desktop\TestPhotos", without quotes, right? Then this isn't a valid mogrify command.benchmarkjoshw wrote:mogrify $path -resize 50%> *.jpg
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2016-11-16T07:51:13-07:00
- Authentication code: 1151
Re: Modify images based on date range?
That is the case, and I have tried pasting the actual C:\Users\Me\Desktop\TestPhotos in place of $path for all parts of the script and it still doesn't want to take. Is there some magic bullet cmdlet that I'm just completely missing?snibgo wrote:$path is "C:\Users\Me\Desktop\TestPhotos", without quotes, right? Then this isn't a valid mogrify command.benchmarkjoshw wrote:mogrify $path -resize 50%> *.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Modify images based on date range?
I can't help you with cmdlets. But this ...
... isn't a valid mogrify command.
For mogrify syntax, type "mogrify" at the command line, or see http://www.imagemagick.org/script/mogrify.php
Code: Select all
mogrify C:\Users\Me\Desktop\TestPhotos -resize 50%> *.jpg
For mogrify syntax, type "mogrify" at the command line, or see http://www.imagemagick.org/script/mogrify.php
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify images based on date range?
For mogrify, you need to cd to the folder you want. Also create a new directory and use -path to specify where the output directory is located. Also use -format to specify the desired output format. See the link that snibgo has shown.
Code: Select all
cd to input directory
mogrify -path path2/outputdirectory -format jpg -resize 50%> *.jpg