Upload image with python - python-2.7

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.

Related

Magick++ to display an image with CGI

I recently began using Magick++ (C++ API for ImageMagick) with the goal of creating a website that could display randomly generated images. I am trying to write a CGI script which would create a JPEG Image, set the color of its pixels, and then return the image information as Content-type: image/jpg.
Reading through the documentation, I only find functions for writing image files to disk. I do not see one which would do what I am hoping to do, along the lines of std::cout << Image or std::cout << Blob
My goal is to be able to display the image generated by the script in a webpage, without needing to write the image to disk.
I know that PerlMagick has a display function which does what I am trying to do - I am wondering if I can do the same with Magick++.
I think you are looking for blobs - Binary Large Objects. Basically, you create an image of type Image and a blob of type Blob. You populate your image either by reading from a file or generating your random data, then you write your image to the blob (to encode it) and you can then write that to the user's browser.
Please excuse my useless C/C++ skills...
Image image;
Blob blob;
// set type to JPEG
image.magick("JPEG");
// generate/read/fill image here
image.read("image.jpg");
// encode image as JPEG
image.write(&blob);
// now send MIME type to browser
std::cout << "Content-type: image/jpeg" << CRLF;
// ... followed by blob
write(1,(char*)blob.data(),blob.length());

How to write the EXIF data intoa saved image file in coldfusion?

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.

Convert PVR.CCZ image to PNG for edit the image.

I need to convert PVR.CCZ image file to PNG image to edit my image file. m original image got deleted. i used texture packer to create pvr file.
i refer this link:- How can I recover PNG images from a .pvr.ccz file? but not useful.
in Googling u will get. i got this link:- https://gamedev.stackexchange.com/questions/69519/how-can-i-batch-convert-texturepacker-pvr-ccz-files-to-png its worked fine also..
Simple command in terminal will help:-
TexturePacker filename.pvr.ccz --sheet filename.png --data dummy.plist --algorithm Basic --allow-free-size --no-trim

Decryption not working on a saved image but works on the pixel manipulated matrix of the image

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

How can I read image metadata from binary blobs?

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)