Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS, How to know whether a photo is a screenshot taken by user? How to delete photos in Photos?

In AppStore(China), an App called Tencent Mobile Manager released a series of functions related to photos, including detecting whether a photo is a screenshot taken by user, deleting photos.

I got screenshots of this app to demonstrate my question here (I added English texts myself for you since the app only shows Chinese):

This app knows what photos are screenshots and what not

When you tap Delete Button at the bottom, it shows:

Asking permission from user to delete photos

As far as I know, Photo APIs (AssetsLibrary, PHPhotoLibrary) in iOS don't give an absolute path of a photo, and iOS SandBox doesn't allow apps to delete user's assets as well, which makes deleting users photos almost impossible. All photos saved in iOS device follows the same naming system: "IMG_001.jpg", which makes it impossible to detect whether a photo is a screenshot from their names.

But apparently, this app implemented both functions. Does anyone have any ideas about this?

Thanks!

like image 394
LuRui Avatar asked Sep 26 '16 08:09

LuRui


2 Answers

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.

Hope this will helps you

like image 53
jignesh Vadadoriya Avatar answered Oct 10 '22 21:10

jignesh Vadadoriya


You can check using PHAsset's mediaSubtypes property.

let types = phAsset.mediaSubtypes /// phAsset is a PHAsset
let isScreenshot = types.contains(.photoScreenshot) /// true if is screenshot
like image 23
aheze Avatar answered Oct 10 '22 22:10

aheze