Tourgueniev <
Tourg...@hotmail.com> wrote:
>On Wed, 15 Oct 2014 01:23:33 +0000, Parko wrote:
>
>> You could also try exiv2. Command line tool, so it may not suit you if
>> you're all gooey like any other creative type. Check your distro's repos
>> if its not installed by default.
>
>I'm doing ok, so far, with the first suggestion, which was exiftool.
>
>At the moment, it moved all the exif tags from one photo to the next,
>but the problem now are the 4 problematic tags:
>File Size : 100 kB
>Exif Image Width : 480
>Exif Image Height : 640
>Image Size : 480x640
As you saw, in a previous post, easy to take care of... :-)
>Googling for how to change exif data on linux, I found these examples:
>
http://dimitar.me/change-the-date-and-time-or-any-other-exif-image-meta-data-of-pictures-with-ubuntu/
>
>This resets the dates to whatever you want them to be:
>exiftool -AllDates='2014:10:10 15:35:33' -overwrite_original new.jpg
>
>Testing that syntax with the 4 obvious exif tags above, I tried this:
>$ ls -l new.jpg
>-rw-rw-r-- 1 root root 67160 Oct 14 23:40 new.jpg
>
>exiftool -File Size='67160' -overwrite_original new.jpg
>But I apparently need to work on the syntax a little bit.
If that would work, it would be, with no spaces in the
tag name.
exiftool -filesize='67160' new.jpg
Arguments are not case sensitive, but of course cannot
have whitespace. Use the -s option(s) to see
unambiguous tag names with no whitespace.
But the file size is not a tag (use the -G option to see
tag groups), it's just telling you what the actual
file size is, and you can't change that with exiftool.
The same happens with the image pixel dimensions, which
will always be determined empirically.
An example of a tougher problem is keeping the
Orientation tag correct. If you rotate an image in an
editor and write it out, the tag may still be for the
original image and will not be correct.
There may be other values that work, but I'm sure of these:
-orientation="rotate 90 cw"
-orientation="rotate 90"
-orientation="rotate 180"
-orientation="rotate 270 cw"
-orientation="rotate 270"
-orientation="normal"
-orientation="horizontal"
-orientation="horizontal (normal)"
Of course there is no way for a program to determine if
it is actually horizontal or a 180 degree rotation, and
the same with 90 and 270.
Since the image pixel dimensions are determined from the
file itself, not from a tag, it is always safe to use
those to calculate what the orientation flag should be.
Here's test script that shows some ways around a couple
pitfalls.
------ start of script ------
#/bin/bash
file="new.jpg"
height="$(exiftool -s -s -imageheight ${file} | cut -d' ' -f2)"
width="$( exiftool -s -s -imagewidth ${file} | cut -d ' ' -f2)"
echo "${width} W x ${height} H"
tagorient="horizontal" # default
#
# Send stderr to /dev/null to avoid seeing thr error if values are not digits
#
# ${result} will be:
# 0 landscape oriented image
# 1 portrait oriented image
# 2 invalid arguments, not digits
#
test "${height}" -gt "${width}" 2>/dev/null; result="${?}"
if [ "${result}" -eq 0 ] ; then
tagorient="rotate 90"
fi
if [ "${result}" -gt 1 ] ; then
echo "Either height (${height}) or (${width}) is invalid."
exit 1
fi
exiftool -orientation="${tagorient}" "${file}"
echo "orientation tag will be: $tagorient"
exiftool -orientation "${file}"
echo "Exit status of exiftool: ${?}"
exit 0
------ end of script ------