Why is dlib's load_rgb_image() method rotating some of my images?Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnailWhy the output image will be rotated?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Lazy load of images in ListViewUnderstanding Python super() with __init__() methodsStatic methods in Python?How do I auto-resize an image to fit a 'div' container?Does Python have a string 'contains' substring method?How to vertically align an image inside a divWhy is reading lines from stdin much slower in C++ than Python?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition
What is this sticking out of my wall?
Number of aircraft to operate in an airline company
How to create a list of dictionaries from a dictionary with lists of different lengths
Are programming languages necessary/useful for operations research practitioner?
What happens to gadgets of players that leave a match
2.5 year old daughter refuses to take medicine
How accurate is the new appraisal system?
Leaving wiggling room for your characters while avoiding contradictions
Which ping implementation is cygwin using?
How do I restrict an interpolated function to only take values > 0?
On the origin of "casa"
Online Education for OR and Developing Decision Support Systems
Is English tonal for some words, like "permit"?
Two different colors in an Illustrator stroke / line
What does the phrase "pinch apart" mean here?
How would two worlds first establish an exchange rate between their currencies
Is there a star over my head?
Why is the the worst case for this function O(n^2)
What causes this bloom with an old telephoto lens?
How does Vivi differ from other Black Mages?
Have there been any countries that voted themselves out of existence?
Why would "an mule" be used instead of "a mule"?
Do any aircraft carry boats?
Is there any detail about ambulances in Star Wars?
Why is dlib's load_rgb_image() method rotating some of my images?
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnailWhy the output image will be rotated?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Lazy load of images in ListViewUnderstanding Python super() with __init__() methodsStatic methods in Python?How do I auto-resize an image to fit a 'div' container?Does Python have a string 'contains' substring method?How to vertically align an image inside a divWhy is reading lines from stdin much slower in C++ than Python?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.
I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.
Check out the results below
img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)
while OpenCV's method returns the correct shape:
img = cv2.imread("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (2592, 1944, 3)
Does anyone have any idea why this is happening?
I am also attaching the image details of one of the offending photos:

python image opencv dlib
|
show 3 more comments
I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.
I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.
Check out the results below
img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)
while OpenCV's method returns the correct shape:
img = cv2.imread("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (2592, 1944, 3)
Does anyone have any idea why this is happening?
I am also attaching the image details of one of the offending photos:

python image opencv dlib
it is on the dlib document thatdlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height
– Ha Bom
Mar 28 at 8:26
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
1
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
1
Some images haveOrientationset in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check withexiftoolor ImageMagick.
– Mark Setchell
Mar 28 at 8:52
1
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59
|
show 3 more comments
I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.
I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.
Check out the results below
img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)
while OpenCV's method returns the correct shape:
img = cv2.imread("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (2592, 1944, 3)
Does anyone have any idea why this is happening?
I am also attaching the image details of one of the offending photos:

python image opencv dlib
I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.
I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.
Check out the results below
img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)
while OpenCV's method returns the correct shape:
img = cv2.imread("myimg.jpg")
print(img.shape)
--------------------
OUTPUT: (2592, 1944, 3)
Does anyone have any idea why this is happening?
I am also attaching the image details of one of the offending photos:

python image opencv dlib
python image opencv dlib
edited Mar 28 at 16:54
Kevin Workman
35.4k7 gold badges44 silver badges78 bronze badges
35.4k7 gold badges44 silver badges78 bronze badges
asked Mar 28 at 8:00
Rafay KhanRafay Khan
1401 silver badge11 bronze badges
1401 silver badge11 bronze badges
it is on the dlib document thatdlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height
– Ha Bom
Mar 28 at 8:26
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
1
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
1
Some images haveOrientationset in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check withexiftoolor ImageMagick.
– Mark Setchell
Mar 28 at 8:52
1
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59
|
show 3 more comments
it is on the dlib document thatdlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height
– Ha Bom
Mar 28 at 8:26
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
1
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
1
Some images haveOrientationset in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check withexiftoolor ImageMagick.
– Mark Setchell
Mar 28 at 8:52
1
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59
it is on the dlib document that
dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height– Ha Bom
Mar 28 at 8:26
it is on the dlib document that
dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height– Ha Bom
Mar 28 at 8:26
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
1
1
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
1
1
Some images have
Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.– Mark Setchell
Mar 28 at 8:52
Some images have
Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.– Mark Setchell
Mar 28 at 8:52
1
1
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59
|
show 3 more comments
1 Answer
1
active
oldest
votes
Thanks to @Mark Setchell, for pointing me in the right direction.
The EXIF data is the key, here.
dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.
Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail
Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392646%2fwhy-is-dlibs-load-rgb-image-method-rotating-some-of-my-images%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to @Mark Setchell, for pointing me in the right direction.
The EXIF data is the key, here.
dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.
Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail
Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
add a comment |
Thanks to @Mark Setchell, for pointing me in the right direction.
The EXIF data is the key, here.
dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.
Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail
Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
add a comment |
Thanks to @Mark Setchell, for pointing me in the right direction.
The EXIF data is the key, here.
dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.
Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail
Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.
Thanks to @Mark Setchell, for pointing me in the right direction.
The EXIF data is the key, here.
dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.
Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail
Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.
edited Mar 29 at 5:28
answered Mar 28 at 9:20
Rafay KhanRafay Khan
1401 silver badge11 bronze badges
1401 silver badge11 bronze badges
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
add a comment |
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.
– Mark Setchell
Mar 28 at 17:03
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL
– Rafay Khan
Mar 29 at 5:27
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392646%2fwhy-is-dlibs-load-rgb-image-method-rotating-some-of-my-images%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
it is on the dlib document that
dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height– Ha Bom
Mar 28 at 8:26
Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.
– Rafay Khan
Mar 28 at 8:38
1
I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github
– Ha Bom
Mar 28 at 8:43
1
Some images have
Orientationset in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check withexiftoolor ImageMagick.– Mark Setchell
Mar 28 at 8:52
1
stackoverflow.com/a/48146220/2836621
– Mark Setchell
Mar 28 at 8:59