I was trying to re save the image file if the orientation was not right. But the issue is when i try to rotate an image and overwrite it to the same file, it works fine but the EXIF informations are not being saved in the overwritten file.
But i want to save all the EXIF data in the new overwritten image as same as the old one except the orientation value. Please help. thanks.
Related
I'm using Django ImageField for user to upload image. I want to read the image directly from InMemoryUploadedFile byte to ndarray for processing. However, some of the images that appeared upright in my folder will be rotated. My images are all mobile phone camera photos. I suspect it is because of the exif info that cause the rotation.
I checked the exif info and it shows <Orientation.LEFT_BOTTOM: 8>. This is same as what I get as the image is rotated 270 degree counter-clockwise. Is there anyway I can read the image from byte to ndarray in upright orientation as per what I see in file explorer?
Below is how I read the image in view.py
upload_file_1 = request.FILES.get('image1', None)
image_1 = cv2.imdecode(np.frombuffer(upload_file_1.file.read(), np.uint8), cv2.IMREAD_UNCHANGED)
p/s: I don't want to save the raw upload image to media folder before postprocessing.
A very beginner in OpenCV
I am trying to implement text steganography: Trying to hide a text message in an image.
What I do is, I hide each of the characters from the text message by modifying the pixels in the image. For each of the characters I take the binary representation of the character and replace the last bit of a pixel with the LSB of the character, and gain last bit of another pixel with the 2nd bit of the character, and so on .... for the whole message.
After this encryption of the text into the image I store it on the disk using cv::imwrite.
This image is again read in by another routine and decrypts it doing the reverse opeartions used for encrypting.
But, the problem is decryption is not working if i read in the image(encrypted image) whihc is stored using cv::imwrite.
But, it works if I pass-on the encrypted matrix (cv::Mat) object to the decryption routine rather than reading a image again.
Seems, something is getting changed when i store the encrypted matrix into an image.
Not sure what is going on behind the scenes. Any help is appreciated.
It sounds like you loose the information when saving.
According to the documentation of imwrite function ( imwrite() documentation ) the function chooses the format of the image based on the extension of the filename you are giving. Could it be that you are using a lossy file format such as JPEG (*.jpg)? instead try using a .png which uses a lossless compression to save the data.
EDIT:
You can use different approach for steganography specially designed for jpeg images: http://www.sav.sk/journals/uploads/0317153109jo-mo.pdf
I have some images (in PNG and JPG format), stored as blobs in the database. I am retrieving them with a query and would like to take action by reading the metadata without writing the image to disk.
I am looking for the file type and image width.
You should be abe to convert the data to a ColdFusion Image type using the ImageNew function as documented here (set the source to be the variable you pulled out of the query).
Once you have the image, you can use the ImageInfo function to retrieve image properties.
This will give you the width. CF won't tell you the original file format, though--it might be easiest to look at magic numbers for that. Wikipedia gives a good summary of what those are and what the values for jpeg and png are: http://en.wikipedia.org/wiki/Magic_number_(programming)
I'm using this command to ftp upload a png image. But when I upload the image is not visible it looks like currupted even if I download it I can't view the image.
Here is the code
ftp.storlines('STOR ' + 'Simple.png', open('Simple.png', 'rb'))
here is the uploaded file
http://llgrow.co.nf/Simple.png
That's because ftp.storlines() is sending the file in ascii mode, you should use ftp.storbinary() for an image file (binary mode):
F=open("Simple.png","rb")
ftp.storbinary('STOR image.png',F,1024)
Try using storbinary()...
Because it takes the binary values of that image... So that no pixel values are messed up...
Since image files contain pixels... Need to store the exact X,Y positions of the pixels.
So storbinary() does that by default.
I am having a bit of a problem.
I get a RAW char* buffer from a camera and I need to add this tags before I can save it to disk. Writing the file to disk and reading it back again is not an option, as this will happen thousands of times.
The buffer data I receive from the camera does not contain any EXIF information, apart from the Width, Height and Pixels per Inch.
Any ideas? (C++)
Look at this PDF, on page 20 you have a diagram showing you were to place or modify your exif information. What is the difference with a file on disk ?
Does the JPEG buffer of your camera contain an EXIF section already ?
What's the difference? Why would doing it to a file on the disk be any different from doing it in memory?
Just do whatever it is you do after you read the file from the disk..
As far as I know EXIF data in JPEG is continuous subpart of file.
So
prepare EXIF data in memory
write part of JPEG file upto EXIF
write prepared EXIF
write rest of JPEG file
You might want to take a look into Exiv2 library. I know it can work on files but I suppose it also has functions to work on memory buffers.