Batch Resize: Difference between revisions
Line 11: | Line 11: | ||
To install ImageMagick, go to Terminal and type: (on Debian/Ubuntu based systems) | To install ImageMagick, go to Terminal and type: (on Debian/Ubuntu based systems) | ||
<pre> | |||
sudo apt-get install imagemagick | |||
</pre> | |||
To resize only, go to the directory of interest: | To resize only, go to the directory of interest and execute a command using find and convert, like so: | ||
Note: This will permanently alter all of your image files! Make sure to copy your image files to a duplicate 'working' directory before running this command. Do '''not''' run these commands in the directory where your original files live. | |||
<pre> | <pre> |
Revision as of 02:23, 1 July 2018
Why
As of 2018, the OSE wiki has a strict upper file size limit of 1M as our OSE Server infrastructure is operating on a very limited budget. For more information on why this is necessary, see Mediawiki#$maxUploadSize
These commands can trivialize the process of doing a bulk resize of images before uploading to the wiki.
Imagemagick
All it takes is one line to resize a directory full of images to your desired size if you have the ImageMagick tools package installed. convert is a tool that comes with that package.
To install ImageMagick, go to Terminal and type: (on Debian/Ubuntu based systems)
sudo apt-get install imagemagick
To resize only, go to the directory of interest and execute a command using find and convert, like so:
Note: This will permanently alter all of your image files! Make sure to copy your image files to a duplicate 'working' directory before running this command. Do not run these commands in the directory where your original files live.
# most robust; handles portrait & landscape images of various dimensions # 786433 = 1024*768+1 find . -maxdepth 1 -iname '*.jpg' -exec convert {} -resize '786433@>' {} \; # or use this if all the photos are the same orientation find . -maxdepth 1 -iname '*.jpg' -exec convert {} -resize 1024x768 {} \;
To resize and convert to another format (example converts JPEG to PNG):
find . -iname '*.jpg' -exec convert {} -resize 640x480 {}.png \;
mogrify
Go into Terminal and change directory to folder with your pictures with whatever percentage reduction yuou need - here it is 25%:
mogrify -resize 25% *
To switch to another format - jpg may be replaced with other formats.
mogrify -resize 50% -format jpg *