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 7680145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:02:40+00:00 2026-05-31T18:02:40+00:00

I have a folder full of html files created for a Kindle ebook. The

  • 0

I have a folder full of html files created for a Kindle ebook. The images are coded with width and height, as per the Kindle guidelines:

<img width="328" height="234" src="images/224p_fmt.jpeg" alt="224p.tif"/>

What I need to create/find is a script that will process all the image tags, multiply the width an height attributes by a specified amount (coded into the script) and write them back into the html files.

So, for the above example, say I want to multiply by 1.5, and wind up with

<img width="492" height="351" src="images/224p_fmt.jpeg" alt="224p.tif"/>

Scripts like this are not my forte, so help appreciated. I especially am unclear on how to write a script that I can run on file(s) from the command line and just input/output html.

I assume the meat of the code would be something like

s/<img width="([0-9]+)" height="([0-9]+)" src="(.*?)" alt=".*"/>/'<img width="'.$1*1.5.'" height="'.$2*1.5.'" src="'.$3.'" alt=""/>'/eg;

Which I realize is incorrect (the multiplication part) which is why help appreciated.

  • 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-05-31T18:02:42+00:00Added an answer on May 31, 2026 at 6:02 pm

    In Python I’d do it like this.

    import sys, re
    
    source = sys.stdin.read()
    def multi(by):
      def handler(m):
        updated = int(m.group(2)) * by
        return m.group(1) + str(updated)
      return handler
    
    print re.sub(r'((?:width|height)=["\'])(\d+)', multi(1.5), source)
    

    Then you can handle input and output on the command like using < and >.

    $ python resize.py < index.html > new_file.html
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder full of html files, some of which have the following
I have a folder full of 100-odd Access97 files. I need to update them
I have a folder full of files and I want to search some string
I have a folder full of .tex files and I would like to write
On my computer running Ubuntu, I have a folder full of hundreds files all
I have a folder full of SWF files. Each SWF is its own animation.
I have a cache folder that stores html files. They are overwritten when needed,
I have a folder full of images which have a format filename.com_XXX_IMG_000.jpg. The issue
I have a folder full of ruby files, and when I try and require
I have a folder full of image files such as 1500000704_full.jpg 1500000705_full.jpg 1500000711_full.jpg 1500000712_full.jpg

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.