Results 1 to 5 of 5

Thread: Filter by image size

  1. #1
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,288

    Default Filter by image size

    I am about to shrink a large number of photo images spread over many directories using mogrify. I would like to filter by two criteria. Whether they are in portrait format or whether they are smaller horizontally than the size I am shrinking to. Is there a method I can use from inside a script? Or perhaps some graphical software that can do the same.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,126

    Default Re: Filter by image size

    You must probably have a method for each type of image file. A JPEG file does store things (including the width and heighth of the image) different from a GIF or an PNG image (and there are more).

    I could offer you ways of finding out for several formats, but would like to know if I can restrict the seaching, for where I have that stored, to a few.
    Last edited by hcvv; 06-Sep-2016 at 04:51.
    Henk van Velden

  3. #3
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,288

    Default Re: Filter by image size

    Quote Originally Posted by hcvv View Post
    You must probably have a method for each type of image file. A JPEG file does store things (including the width and heighth of the image) different from a GIF or an PNG image (and there are more).

    I could offer you ways of finding out for several formats, but would like to know if I can restrict the seaching, for where I have that stored, to a few.
    Thanks for the speedy response and your kind offer. All the photos are in JPEG format.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,126

    Default Re: Filter by image size

    Well, you could look into the JPEG itself (I have a piece of ksh script doing that), but maybe the easiest interface is the program jhead. It can be installed from the OSS repos (the package name is also jhead).

    One can manipulate JPEG headers with it, but you only want some information. Calling it without any additional options will give you something like (this is the minimum, there might be much more):
    Code:
     jhead RASC-Eviii.jpeg 
    File name    : RASC-Eviii.jpeg
    File size    : 76190 bytes
    File date    : 2015:09:18 12:16:16
    Resolution   : 584 x 750
    JPEG Quality : 75
    You are interested in what here is called the Resolution:
    Code:
    jhead RASC-Eviii.jpeg | grep '^Resolution'
    Resolution   : 584 x 750
    And that is of course a good start for further processing in a script.
    Henk van Velden

  5. #5
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,288

    Default Re: Filter by image size

    This is exactly what I need to get me started. Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •