[Nottingham] Tweaking the orientation flag in a jpeg
Martin
martin at ml1.co.uk
Thu Sep 2 23:03:26 UTC 2010
On 01/09/10 14:25, Martin wrote:
> On 01/09/10 12:44, Graham Dicker wrote:
>> Hi everyone
>>
>> Does anyone know of a utility that can modify just one byte at a given offset
>> in a file? I want to change the orientation flag in a set of jpegs for which
>> lossless rotate is not an option. The flag is at the same offset in every file
>> and just needs to be changed from a 1 to a 6.
>
> Clever use of "dd";
Roger gets the prize for a fast solution. The only minor improvement to
be made there is perhaps to use mmap to tweak the file in situ.
The dd trick is:
dd bs=Offset-1 count=1 if=File of=FileNew
echo 6 >>FileNew
dd bs=Offset skip=1 if=File >>FileNew
with no test whether the target byte is a "1" or not.
That really would need to be wrapped up as a bash script...
Cheers,
Martin
--
----------------
Martin Lomas
martin at ml1.co.uk
----------------
More information about the Nottingham
mailing list