Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8648701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:22:27+00:00 2026-06-12T13:22:27+00:00

We have been capturing and sending files to a REST server and saving them

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:22:28+00:00Added an answer on June 12, 2026 at 1:22 pm

    Try this script

    #!/bin/bash
    SEARCHPATH=$1
    COMNUM=$2
    FINDEXT="*.png"
    
    for f in `find $SEARCHPATH -type f -name $FINDEXT` ; do
         #just get files name without extension
         fname=`echo $f | cut -d'.' -f1` 
         #perform operations
         cp $f ${fname}.b64
         /bin/base64-to-png.py $f $f
         mogrify -quality $COMNUM -format png $f
    
    done
    

    you can call it as

    $ base64-to-png.sh /somepath/tofind 100
    
    param 1 : path where to find `.png` files 
    param 2 : compression number.
    

    This assumes that /bin/base64-to-png.py can work on absolute path e.g. /somepath/somedir/somefile.png not just somefile.png

    Warning: no QA done, use it on your risk!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have have been trying to make a validator for my xml files. I have
I have been working with SQL Server as a Developer a while. One thing
I know that log4j by default outputs to stderror. I have been capturing the
I have been capturing exceptions and redirecting users to an error page. I pass
I have been experimenting with capturing click events outside of elements using stopPropagation() .
I have been using blocks for some time now, but I feel that there
I have been banging my head against this for some time now: I want
I have just realised I have been capturing the wrong data for one column
Have been trying to encrypt an xml file to a string so that I
Have been working on this question for a couple hours and have come close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.