We have been capturing and sending files to a REST server and saving them to PNG extensions from a toolbar, now have nearly a half a million files.
Recently we found they have been actually saving as base64 streamed files and not PNG format.
I have a python script that can convert them but is not recursive and connot use wildcards.
ImageMagick says the base64 files are too big(5K max) so thats out for the conversion.
IE; /bin/base64-to-png.py <base64_file_name>.png <output_name.png>
The directory paths /mnt/s3/pages/ where “pages” has several thousand numbered folders.
IE; /mnt/s3/pages/100
"pages" subfolders are never more than 1 folder deep.
The files are typically 5540_thumb.png, 5540_snapshot.png and 5540_crop.png
where the 5540 is the capture number.
I need a BASH script wrapper to make it recusive accross the folders, copy all originals to backup files (filename.b64) and pass wildcards as proper path/names to the python script, convert the files and leave the output file in the same respective folder then use mogrify to compress them.
IE; base64-to-png.sh *_snapshot.b64 *_snapshot.png <compression number>
should
cp <file_name.png> <file_name>.b64
/bin/base64-to-png.py <file_name.png> <file_name.png>
mogrify -quality <compression number> -format png <file_name.png>
Try this script
you can call it as
This assumes that
/bin/base64-to-png.pycan work on absolute path e.g./somepath/somedir/somefile.pngnot justsomefile.pngWarning: no QA done, use it on your risk!