Suppose, there is a PHP file in mac os x, or any other file except JPEG, JPG, or PNG.
If I click, and change extension, as below
Now, if I choose Use .png, it will become a png file, and can be seen in iOS Gallery.
Now, if a person uploads this to server, as profile picture or any way, how can I check that whether it is real image or has something else in form of PNG or JPG.
NOTE: This is only to avoid hackers or harmful scripts.
Thanks.
Try mime_content_type(), then make conditions by type .. http://php.net/manual/en/function.mime-content-type.php
Related
I'm trying to use
CGImageSourceCreateWithData
CGImageDestinationCreateWithData
and then
CGImageDestinationAddImageFromSource
but this discards any thumbnails or other embedded information in the original file. What I want to do is read in the file, alter its metadata, and write it out with the alterations only. But I'll settle for reading everything out of it, and putting it back again. Right now a 1.2MB image file gets converted to a 437kB file with the loss of additional data.
Is there something other than CGImage I can use? Can this even be done with the iOS API?
The problem you face is that the structure of the metadata depends upon the specific JPEG file format you are using.
You need to look at CGImageProperties. You're going to have to make sure the properties for your specific file format get copied as well.
What I was looking for was a read-modify-write operation for image files that allowed changes but otherwise maintained unaltered data. I've determined through research and testing that this is not possible in iOS. The closest mechanism available is CGImage processing, but this only allows you to read selected information from a source image (such as image, thumbnail, properties), and then use some of that information (image, properties) to create a new destination file. There's no way to include a thumbnail in the new destination file, and no way to get around recompressing the image.
As of iOS 7 you can use CGImageDestinationCopyImageSource "to modify EXIF and other image metadata in JPEG, PNG, PSD, and TIFF files without recompressing the image data"
https://developer.apple.com/library/archive/qa/qa1895/_index.html
User uploads image in browser. On server side I generate preview. I want to remove metadata from preview image. Options:
Remove everything (EXIF, ICC) and save image with the color scheme profile it was uploaded. Is it safe? Will ImageMagic process such images correctly? Will browsers display this properly?
Remove everything and convert the preview to sRGB.
Check ICC color profile and if it is not sRGB - do not remove it.
Any other ideas? Which approach would you reccomend / use in your projects?
Thanks,
The hump you face is dealing with the various forms of JPEG file formats.
In a JFIF file, you could remove all the COM and APPn markers (save APP0), to clean out the metadata and have a readable file.
In an Exif file, APP1 is used in place of JFIF's APP0. However, the EXIF APP1 marker can include metadata.
One thing you could try is to simply strip out all APPn and COM markers. It is likely that many browsers would be able to read JPEG streams without a file format specified and that the would assume a 3 component stream is YCbCr and a 1 component stream is grayscale.
Another solution would be to convert everything to JFIF.
I have an existing Cocos2D game that uses sprite images taken from a .pvr.ccz file, probably generated by TexturePacker. However, I don't have the original PNG images used to create that file, and I need to make some changes to the images in the game. Are there any tools or techniques that I can use to pull the images out of the .pvr.ccz file, or do I need to write my own tool?
Not possible if they use the encryption option of Texture Packer:
I've added a new feature to TexturePacker which helps you to prevent all this from happening. It's called ContentProtection and simply encrypts the images.
Your app will still be able to decrypt the data, but somebody else is going to have a hard time getting it done.
Source: https://www.codeandweb.com/texturepacker/contentprotection
I want to display the favicon.ico from websites on my blackberry application. I would normally use the EncodedImage class to convert the byte[] into a recognizable image file. However EncodedImage only supports PNG, BMP, JPG, TIFF, and GIF. Is there another method for me to display the ICO file on the device?
You right. Encoded image don't support icon files.
You may try to find and/or port to J2ME one of open-source library.
Also you can try to create yourself realisation of EncodedImage.
And, in the end, you can use services like convertico.com to convert .ico online or write yourself simple web-side script.
I have decided to use Google's supposedly undocumented favicon service that converts .ico to .png in a 16x16 format.
http://www.google.com/s2/favicons?domain=blackberry.com will return blackberry's favicon as 16x16 png.
Does anybody know how to create a thumbnail from an Adobe Illustrator file without using Illustrator? I have a php/linux based application and I'd like to do so.
-Dave
By default, Adobe Illustrator saves files as PDF compatible. Unless the file was saved in a strange way, you should be able to use ImageMagick directly to generate a thumbnail. For example:
convert file.ai -thumbnail 250x250 -unsharp 0x.5 thumbnail.png
Note: If the file has multiple artboards (which are interpreted as pages as a PDF), it will generate multiple files or, if saved as a GIF, an animated GIF.
If you can save it in PDF, PS, or EPS format you may be able to manipulate it in things like ImageMagick or Ghostscript.
EDIT:
I think you can actually use ImageMagick's convert with *.ai files as well.