Jump to content

Recommended Posts

Posted

Is there anyone who knows if is there a software for mac than can provide batch resize and smart crop?

I just noticed this.

You can use Preview to do batch resize. Drag to select or hold down Command to select multiple images in Finder or on the desktop. Double-click any of the selected images to open in Preview. In the list of images in Preview's right side panel, hold down Command while clicking to select multiple images. (or use Command+A to select them all) Then use the same procedure you would to resize a single image in Preview.

I can provide screenshots if you want them.

Posted

I'm trying to find a way to automatize "crop and resize" functions.

What I'd like to obtain is a simple procedure (could be even a "copy a file and double click on it") that take in input the original images from LDD and generate ready thumbnails.

For windows I'm working with Irfanview, but it seems I've some problem with transparency.

For MAC, I don't know if there is a free software that can achieve this goal.

The procedure you listed above don't have a smart crop function, than it is not what I'm looking for.

Posted (edited)

Probably a long shot, since the setup isn't common, but if you have webserver software installed with PHP and Imagick, this script will process a directory of images by removing empty borders and resizing to a default size, or one specified by a query string (e.g. resize.php?size=256).

<?php

   if (isset ($_GET['size']) && is_int ($_GET['size']) )
   { define ('SET_THUMB_SIZE',    $_GET['size']); }
   else
   { define ('SET_THUMB_SIZE',    '512'); }

   define ('DIR_PREVIEWS',    SET_THUMB_SIZE . '/');

   // Create output directory if it doesn't exist (will be named according to the value of "SET_THUMB_SIZE"
   if (!file_exists (DIR_PREVIEWS) ) { mkdir (DIR_PREVIEWS, 0777); }

   $list    = glob ('*.png'); // .jpg can also be processed, simply change from .png
   $thumb    = new imagick ();

   foreach ($list as $name)
   {
       // Skip existing thumbnails, in case the script times out while dealing with hundreds of things,
       // you can just refresh the page and continue where you left off
       if (file_exists (DIR_PREVIEWS . $name) ) { continue; }

       $path    = realpath ($name);

       $thumb    -> readimage ($path);
       $thumb    -> trimimage (0); // "Tolerance" for border detection - change this to work even on lossy JPGs
       $thumb    -> setimagepage (0, 0, 0, 0);
       $thumb    -> thumbnailimage (SET_THUMB_SIZE, SET_THUMB_SIZE, true);
       $thumb    -> writeimage (DIR_PREVIEWS . $name);
       $thumb    -> clear (); $thumb -> destroy ();
   }

?>

This has saved me a lot of time and I want you to have it.

Edited by Gnac
Posted

Thanks, very useful.

I already thought to an online solution, but it has a limit: if you have not a line that ensure you a fast upload, the process is very slow.

Or do you intend to use it in locale?

PS: what do you mean with "trimming non-transparent areas"?

Usually the portion of the image that need to be cut out is transparent (transparency obtained using Alpha Layer).

Posted (edited)

Agh, I described "Trimming non-transparent areas" wrong. It works just as you describe - "trimimage (0)" will trim all horizontal and vertical borders which are transparent (or even a solid colour), leaving just the centre part of the image with all the detail. The zero controls the tolerance, so higher values should work even on JPGs with compression artifacts.

The script can be executed online, but yes, I run it on my laptop using a nice local webhost package called XAMPP.

Because ImageMagick is a commandline app, it can be used easily with many scripting languages, so perhaps Python or something similar might be easier than setting up a localhost just to use PHP.

EDIT: There is an even easier way, and it was right under my nose: ImageMagick includes a commandline tool called "mogrify", which is suited for batch processing. Best of all, it's cross-platform!

mogrify -trim -fuzz 0 +repage -thumbnail 256x256 *.png

This will do the same trim and resize operations on a directory of files as the PHP script above, BUT it will overwrite the original files.

Edited by Gnac
Posted

The problem is that create a local webserver is too difficult for the great part of the users.

The "ideal" thing would be a simple file that executed inside a directory containing the images will create cropped and resized thumbnails, but I didn't find nothing similar. I'm working with irfanview but unfortunately it seems to be unable to manage alpha channel transparency correctly.

If you want to create a complete "step-by-step" guide for your script, I'll post it in the first page.

You could sent it to me using private messages.

  • 2 months later...
Posted

Added a little guide that shows how to use ImageMagik to execute batch crop and resize of the images.

It is a WIP still, any contribute for MacOS and Linux will be appreciated.

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...