//************************************** // Name: Save Lock Windows Images // Description:Partly this is an exercise to demonstrate the versatility of PHP... There ARE other ways to accomplish the same thing... However, that being said... If you like the Windows 10 Lock Window Imagaes and would like to put some or all of them into a gallery (eg. your Background Slideshow, this procedure may be of interest to you. The Lock Window Images are temporarily stored in a deeply 'hidden' folder and periodically changed so that if you do want to save them it is necessary to run this script at least as often as you notice them change. // By: David Leatherman // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** <?php /* Partly this is an exercise to demonstrate the versatility of PHP... There ARE other ways to accomplish the same thing... However, that being said... If you like the Windows 10 Lock Window Imagaes and would like to put some or all of them into a gallery (eg. your Background Slideshow, this procedure may be of interest to you. The Lock Window Images are temporarily stored in a deeply 'hidden' folder and periodically changed so that if you do want to save them it is necessary to run this script at least as often as you notice them change. These files all have 64 random character names with no file extension and not all of them are valid jpeg files. 1 - Copy everything in the 'hidden' folder to your working folder, renaming them with a sequentially assigned name and a .jpg extension This will make the valid files identifiable (as you will see, later in the process) 2 - Create an array of these file names to distinguish them from the jpeg files you already have in your working directory, 3 - For every file name in that array a. Remove (unlink) files whose file size is less than 150 bytes (smaller are of no interest, IMO). b. Verify that it is a genuine jpeg file (looking for EXIF information), removing files that are not. c. Get the Image Dimensions (height and width) d. Here I excluded portrait and square images (that gives me landscape images to better fit my screen). e. Files that are accepted, are listed, just to inform you what you will be looking for (see below). 4 Execute a shell command to open a viewing window to the working directory in order to examine the accepted files. 5. You can then sort the files to bring the new files to the top of the list to pick those you do or don't want to keep. 6. Rename the new files to something more interesting - you could extract exif descriptions for renaming ideas. There may be duplicates, as time goes on, because Microsoft will randomly put the same images back in the 'hidden' folder. I compare file sizes of the files in the wworking directory to eliminate these cases. */ $private = "\your_folder"; // Distinguishing filepath unique to your computer - change to your computer name $winpath = "C:\Users" . $private . "\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"; $wrkpath = "D:\DATA\Lock_Window_Images"; // Where you want to keep your gallery of images $number = 1000; $dirlist = array(); if ($handle = opendir($winpath)) { while (false !== ($entry = readdir($handle))) { if (($entry != ".") and ($entry != "..")) { $srce = "$winpath\\$entry"; $dest = "$wrkpath\\$number.jpg" ; copy($srce, $dest); $dirlist[] = $dest; $number++; } } closedir($handle); } $dcount = count($dirlist); for ($n=0; $n<$dcount; $n++) { $name = $dirlist[$n]; $fsize = filesize($name) / 1024 + .5; if ($fsize < 150) { unlink($name); continue; } if (exif_imagetype($name) != IMAGETYPE_JPEG) { unlink($name); continue; } $img = ImageCreateFromJpeg($name); $width = imagesx($img); $height = imagesy($img); if ($width <= $height) { unlink($name); continue; } echo "[" .number_format($fsize,0). "] [" .$width. " x " .$height. "]" .$name. "<br>"; } $output = shell_exec('start ' . $wrkpath); ?>