[Nottingham] Tweaking the orientation flag in a jpeg

Camilo Mesias camilo at mesias.co.uk
Fri Sep 3 07:00:02 UTC 2010


Is that an ASCII '6' not an integer 6 though? Is that what's intended?
I'd check the file before and after with hexdump or similar just to be
sure. I wonder what orientation 0x36 is? :)

-Cam

On Fri, Sep 3, 2010 at 12:12 AM, Martin <martin at ml1.co.uk> wrote:
> On 03/09/10 00:03, Martin wrote:
>> 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...
>
> Instead, you could also do:
>
> echo 6 | dd bs=1 count=1 seek=Offset of=File
>
> to write the '6' in situ...
>
>
> Cheers,
> Martin
>
> --
> ----------------
> Martin Lomas
> martin at ml1.co.uk
> ----------------
>
> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham
>



More information about the Nottingham mailing list