Clear Filters
Clear Filters

I rotated images in preview (mac), but Matlab views original images

2 views (last 30 days)
Hi
I have tousands if images rotated in preview (mac). I didnt know, what exif is and that some programs - like matlab - view the original, not rotated images. I am trying minimize the damage and I am looking for a fast solution to rotate the images in matlab.
I've tried:
imfinfo('image.jpg')
struct with fields:
Filename: 'image.jpg'
FileModDate: '12-Apr-2021 19:34:46'
FileSize: 41389
Format: 'jpg'
FormatVersion: ''
Width: 612
Height: 1101
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
Orientation: 8
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
YCbCrPositioning: 'Centered'
DigitalCamera: [1×1 struct]
so there is information about the orientation. What does the 8 mean?
If i rotate this image, the 'Orientation' information disappears.
xx = imrotate( image , 90);
imshow(xx)
imwrite(xx, 'test.jpg')
imfinfo('test.jpg')
Filename: 'test.jpg'
FileModDate: '16-Apr-2021 12:18:34'
FileSize: 42262
Format: 'jpg'
FormatVersion: ''
Width: 1101
Height: 612
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
Can I change the 'Orientation' or do something with it to make the images be rotated like in Preview?
Best,
Dawid
  2 Comments
Jan
Jan on 16 Apr 2021
"If i rotate this image, the 'Orientation' information disappears." - No, this information vanishes, if you write the image to the disk.
"I have tousands if images rotated in preview (mac)" - What does this mean? I'm not sure if I understand, what your current situation is. Yout can rotate images in the preview of the operating system? Then MacOS writes "8" as orientation? Which value is found there, if you rotate in another direction?
So what exactly are the data you have and what do you want to achieve? What is the relation of your problem to Matlab?
Rik
Rik on 16 Apr 2021
If you want to rotate the actual images themselves, why don't you do that? You can use the orientation property to find out how you need to rotate or flip the image. It takes some experimentation, but it isn't hard.

Sign in to comment.

Accepted Answer

Dawid Strzelczyk
Dawid Strzelczyk on 16 Apr 2021

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Tags

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!