How to save a photo with custom filename using PHPhotoLibrary on iOS/Swift 2? - swift2

I'm trying to save an image with a custom filename with PHPhotoLibrary but it for me is impossible. The filename of image always is IMG_XXX.JPG. I get its filename from photos program.
I don't see the filename in my iPhone.

Filenames within the Photos library are an implementation detail. They're not exactly private, but they aren't there as something for you to mess with or rely on the stability of. (For example, if you grab the underlying image file for an asset, it'll have one name, but that name may change if the user edits that asset in the Photos app or it gets uncached and re-downloaded from iCloud Photo Library.)
You can get a filename when you read an asset from the Photos library, simply as a side effect of being able to get an original file. You're not allowed to set filenames in the Photos library, because Photos manages its own storage.
And of course, if you read an asset's original file and want to save a copy of it somewhere else, you can give that copy whatever filename you want.

Related

Is there a way to link yet to be created images into an indesign layout?

I'm creating a multipage publication with many ads that haven't been built yet. I know their size, and filename, but the image/pdf doesn't exist yet.
Is there an existing script or a possible way to link an image that doesn't exist? Another way to look at this would be kind of the reverse of how the missing links (relink) button works. Where I know what the file path will be, but the file is missing.
Publishing industry standard practice:
Rather than a script, just create a blank image at the exact size. Make it florescent magenta with the letters "FPO" huge and dead-centre so no one can mistake it for the real thing.
Importantly: give this FPO image the exact file name of the file which will eventually be used/placed.
When your production image is finalized and approved, cut-and-paste the exact FPO file name into the new file. Drop the production file into your working directory overwriting the FPO file, and refresh it in InDesign. Bob's your uncle.
If this is being done to hundreds of images, you can develop your own batch process to handle this with some time-saving automation. However, this is a good example of an issue that can be solved at the production-management level, rather than at the coding level.
Hoping this helps!

Resource pictures not include in directory

I am creating a vb6 application now and most of my command buttons were graphical style. Do the background images still show up even if I remove them from the app folder?
This is part of what goes into .FRX, .CTX, etc. files. Those are resource files created in a private "property bag" type format and are used to hold things like binary data, images, long strings, and so on.
But don't discard your source files, because you may need them down the road. Treat such things as valuable parts of the program source. They are not needed at run time though.
As far a I know it doesn't remove the picture from the command button when you delete it from the app folder, i suggest making a copy of your image and then delete the original and see if it works in case it doesn't you have the backup image, good luck.

How to link or add a default directory for images in Visual Basic

So I've been working on this simple program to look up specs for drawings. One of the specs is a thumbnail image of the drawing. I didn't want to try managing what could be 1000's of images (that could be changed at anytime) in the database so I created a true/false field instead. If true for that record, then the corresponding thumbnail is displayed in a picture box.
It works beautifully.... if I type the entire path in the code. But what if I give the program to a friend? So I've been trying to find a way that the program would find the images to no avail. I've been searching for answers all day and am finally at this point.... asking for help.
If CBool(db.getField("PDF")) = True Then
'pbxPDFThumb.ImageLocation = ("C:\Users\Reed Havoc\Desktop\RCM Database\RCM DataBase 2015 8g\RCM Plans Tool\RCM Plans Tool\Thumbnails\PDFs\" & db.getField("Plan_Num") & "pdf.jpg")
pbxPDFThumb.ImageLocation = ("\Thumbnails\PDFs\" & db.getField("Plan_Num") & "pdf.jpg")
End If
The first line is the entire path commented out to try the second, foreshortened path.
I've been adding my image thumbnail directory to the project in all the different directories that VS establishes on start-up but none seems to be a default so that my added image directory will be recognized.
Not so clear so I'll have 2 answers.
If drawing are not going to be added but you only use the ones you already have, simply store all of the pictures in the project's resource file, which is accessible through code and builds into the EXE
If the user adds drawings themselves there are two options. There's the more user friendly method: Save the files in a Local appdata folder for the application.
Or, less user friendly and ultimately more work for you. when the application starts, ask the user to identify a directory that does / will contain images.

What are Default Picture Names from the Hardware Camera

I noticed that depending on how an image was taken or saved to the Windows Phone device, a different naming scheme may be used. For instance, a picture taken from the default camera application and saved to the Camera Roll will be WP_20131108_001.jpg, and a picture from screenshots would be wp_ss_20131108_0001.jpg, while the Saved Pictures album naming convention seems to be random based on where the picture came from. Is there a systematic naming scheme for pictures in different albums?
I need the ability to know when a picture was taken with my application or not in case it is used later (and it may be chosen from the PhotoChooserTask). I was thinking if there is no standard way to tell where a picture came from, then when saving an picture from my app I could put in a certain text value in the name and then check to see if a picture's name contains that text when being used in my app, and in that way flag to know whether a picture originally came from my application or not. Any suggestions?
You can use Album.Name functionality of Picture class to get the album name/source folder where the picture came from.And while saving in cameraroll or saved pictures you can provide a custom name for your picture.
fileName = "Camera_" + DateTime.Now;
MediaLibrary library = new MediaLibrary();
library.SavePictureToCameraRoll(fileName, stream);

Image upload security. GD enough? when do I use it?

According to Secure User Image Upload Capabilities in PHP, the recommended way is to manage images uploading's security is to copy the incoming image with GD/ImageMagick/... (and set it with a random name).
Ok. I have the following questions.
1st.
In our page we have the possibility of cropping the image. So:
First we download the image uploaded by the user, saving it in temp with a random name.
Then we load it in our view so user can crop it.
The image cropped is created with GD.
Is it risky to load the image without having processed with GD first?
2nd
Is process the image with GD enough? I've seen this answer: Block upload of executable images (PHP)
which says is not (in opposite to the first link and other answers I've seen on topic).
Thanks!
PS: Programming with Codeigniter.
1st:
That should be good enough. Make sure that the images are only temporarily accessible and are deleted right after everything is done (I would probably also set up a cron job to clean the temporary image directory every so often, but that depends where you store it). As said in the answer you posted, remember to sanitize name and also make sure you have correctly set permissions. Also beware of null byte injection and directory traversal (again just repeating the answer you mentioned).
I would then check whether the image is valid by using getimagesize to ensure it's an actual image and that's about it.
There are also client side html5 solutions, where you evade this problem completely, but of course it means that it won't work with older browsers.
And of course don't trust what the content type it says it is.
2nd:
Yes I would have thought, first try getimagesize, if you get valid then process with GD. Optionally you can also whitelist extensions, if that's something you are not doing.

Resources