Reputation: 123
I have four images, each slices of a larger image. If I string them together horizontally, then I get the larger image. To complete this task, I'm using python 2.7 and the OpenCV library, specifically the hconcat() function. Here is the code:
with open("tempfds.jpg", 'ab+') as f:
f.write(cv2.hconcat(cv2.hconcat(cv2.imread("491411.jpg"),cv2.imread("491412.jpg")),cv2.hconcat(cv2.imread("491413.jpg"),cv2.imread("491414.jpg"))))
When I run it, everything works fine. But when I try to open the image itself, I get an error: Error interpreting JPEG image file (Not a JPEG file: starts with 0x86 0x7e)
. All the images I'm using are jpg's, so I don't understand why this error is occurring. Any insight is appreciated.
Upvotes: 0
Views: 631
Reputation: 208107
If you want to write a JPEG, you need:
cv2.imwrite('lovely.jpg', image)
where image
is all your images concatenated together.
Upvotes: 2