How to put two pictures next to each other?

I have a landscape and a portrait image, and I want to put them next to each other to form a single picture, so I want to resize the landscape height to be equal to the portrait width. jpg pictures

Answers (1)

6 Comments

my first problem is that imread rotates my image to landscape automatically, so I cannot figure out its original aspect ratio!
I have a landscape and portrait figure: fig1.jpg, fig2.jpg
but
A = imread('fig1.jpg'); B = imread('fig2.jpg');
disp(size(A)); disp(size(B));
results the same!
Why?
imread() does not rotate images. Use
imfinfo('fig1.jpg')
imfinfo('fig2.jpg')
and you will likely see that they are the same dimensions in the file.
There might be padding in different places in the images.
Mr M.
Mr M. on 15 Dec 2015
Edited: Mr M. on 15 Dec 2015
I took the photos with my camera, and they are really landscape and portrait. It is already checked by Preview. But disp(size(imread())) are the same, which means the portrait is rotated, isn't it? How can you interpret this?
It sounds as if the EXIF Orientation header is set in the image; see http://www.impulseadventure.com/photo/exif-orientation.html
You can read the EXIF information using http://www.mathworks.com/help/matlab/ref/exifread.html to determine which direction you need to rotate the images. After that, you can imresize() and then you can use image() with XData or use montage() to put the images side by side.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 15 Dec 2015

Commented:

on 15 Dec 2015

Community Treasure Hunt

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

Start Hunting!