Can I detect if an imported ALAsset photo was taken via screenshot?

℡╲_俬逩灬. 提交于 2019-12-09 13:05:13

问题


I have an imagePickerController that is used for importing photos from library into my app.

When in ALAssetsLibraryAssetForURLResultBlock, I'm trying to find out if the ALAsset I've got in the block is a photo taken as a screen-shot or is it a "genuine" photo, taken by the camera.

I've tried to go through the ALAsset's metadata dictionaries but couldn't find any flag / indication that might fit.

Anyone have any ideas?


回答1:


For screenshot, its UTI is always a "public.png" and same size as screen (be sure you have multiply [UIScreen scale] on screen bounds width and height), just need to check these 2 metadata, you can easily identify screenshot.




回答2:


Add MetaData to UIImage while saving to Photo Library. Same metadata of UIImage can be used to know if its screenshot or not.

Refer Save_Photo_to_Album_with_Metadata




回答3:


Well, I was researching and experimenting .. and the closest solution I've found is based on the fact that iPhone screenshots don't yield EXIF records (while all other generated photos do generate them).

Therefore, once a photo is selected in the picker, I'm checking if the photo's metadata consists an EXIF record and if it doesn't - I conclude that the photo was screenshot.

I found it's the "as good as it gets" solution for now, although it's not an official one.

Cheers.



来源:https://stackoverflow.com/questions/12953669/can-i-detect-if-an-imported-alasset-photo-was-taken-via-screenshot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!