Main Menu

editing height and width

Started by bdcrane, October 22, 2016, 06:09:26 PM

Previous topic - Next topic

bdcrane

I need to be able to change the image size, height and width fields in the exif data (e.g. change 3000x4000 to 4000x3000). Is this possible?

Phil Harvey

You may change ExifImageWidth and ExifImageHeight only, because these are metadata.  But changing the actual image dimensions would require an image editor, so you can't do this with ExifTool

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bdcrane

Thanks Phil. I've struggled a bit with the documentation, and haven't figured out what the syntax for the command would be. I tried using one of the examples as a template, but it didn't work. Can you help point me in the right direction? Thanks.

Phil Harvey

The syntax to write ExifImageWidth and Height?  Here it is:

exiftool -exifimagewidth=4000 -exifimageheight=3000 FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bdcrane

Thank you, that worked.

But it looks like in addition (or maybe instead) I need to change "Image Size = 4000x3000" to "Image Size = 3000x4000"

I tried:
exiftool -exifimagesize=3000x4000 FILE

but got the error:

Warning: Tag 'exifimagesize' is not supported
Nothing to do.

Is there a way to do what I need?

Phil Harvey

The ExifTool "ImageSize" tag is a Composite tag based on ImageWidth and ImageHeight.  None of these are writable because they represent the actual dimensions of the image, and ExifTool can't be used to edit the image.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bdcrane

I think I may have been looking at the wrong metadata. I now see that there is for portrait images:

Orientation                     : Rotate 270 CW
Rotation                        : Rotate 270 CW

Where I may need how these metadata read for landscape images:

Orientation                     : Horizontal (normal)
Rotation                        : Horizontal (normal)


Hayo Baan

So basically you just want to rotate the image (without changing the pixels)? That's quite easily done, you just need to know how you want it rotated. There are lots of possibilities, including mirroring (what you probably don't want), but I think you just need either:
exiftool -orientation="Horizontal" -rotation="Horizontal" DIRorFILE (for landscape)
exiftool -orientation="Rotate 90 CW" -rotation="Rotate 90 CW" DIRorFILE (for rotated right), or exiftool -orientation="Rotate 270 CW" -rotation="Rotate 270 CW" DIRorFILE (for rotated, left).

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Alan Clifford

I've had a camera that puts in two orientation tags which has caused me problems.  You can check with
exiftool -a -orientation FILE

bdcrane

Thanks for the suggestion Hayo. I just tried that, but got the following error:

Warning: Can't convert Nikon:Rotation (not in PrintConv)
Warning: Can't convert IFD0:Orientation (not in PrintConv)
    0 image files updated
    1 image files unchanged

I doubt it matters, but the file is not from a Nikon; my camera is a Lumix G1

Phil Harvey

Works for me:

> exiftool -orientation="Horizontal" -rotation="Horizontal" PanasonicDMC-G1.jpg 
    1 image files updated
> exiftool -orientation="Rotate 90 CW" -rotation="Rotate 90 CW" PanasonicDMC-G1.jpg
    1 image files updated
> exiftool -orientation="Rotate 270 CW" -rotation="Rotate 270 CW" PanasonicDMC-G1.jpg
    1 image files updated


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bdcrane

When I try that, I get the following error:

Warning: Can't convert IFD0:Orientation (not in PrintConv)
Warning: Not an integer for NikonCapture:Rotation
    0 image files updated
    1 image files unchanged

I checked support table that lists all of the supported exif tags. I see that orientation has 8 numerical values associated. 1= Horizontal (normal) which seems to be what I want. So I tried:

exiftool -orientation=1 FILE

And that worked!     Kind of....

When I checked the exif data again, orientation had changed to "Rotate 180" rather than "Horizontal." But I may be OK. The whole point of this is to be able to bring portrait and landscape images into Agisoft Photoscan (3D photogrammetry software), and have that software recognize both kinds of images as being within a single calibration set, rather than thinking they represented two different "cameras" and treating those as 2 calibration sets. Now I seem to have kind of garbled exif data (if I do exiftool -a -orientation FILE I get three records with two values: "Rotate 180" and "Rotate 270 CW"), but it seems to be fooling Photoscan into doing what I need, so.....

Phil Harvey

Either you are using a seriously old version of ExifTool (the current version is 10.33), or there is some typo in your command, because that should have worked.

Typing "-orientation=1" should set the value to "Rotate 180" because the "1" matches the start of "180" in that string.  So that at least seems to be working.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bdcrane

It was a typo with the quotation marks. Sorry.  Thanks for your patience with me.

Is there a way to do this for a batch of photographs?

Phil Harvey

Quote from: bdcrane on November 15, 2016, 01:39:09 PM
Is there a way to do this for a batch of photographs?

Yes.  You can put as many file names and/or folder names on the command line as you want.  For example, to do all images in the c:\images directory:

exiftool -orientation=horizontal c:\images

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).