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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:41:44+00:00 2026-05-26T05:41:44+00:00

I am using canvas to manipulate images, crop, resize and optimise before uploading them.

  • 0

I am using canvas to manipulate images, crop, resize and optimise before uploading them.

I am using the toDataUrl() method to get the image data once it has been manipulated. I have the base 64 encoded PNG url from this.

I know the file size of the image to begin with but am unsure how to get the file size of the image after it has been cropped etc… Without uploading the image.

Getting the length of the data url seems to have no relation to the image size as far as I can see… and I am unsure how to get the information that I am looking for: The file size of the image data after manipulation, from the base 64 encoded PNG url.

Uploading the image at this point is kind of defeating the purpose as I need all of this to be done client side. I just need to ensure that the image is < max before uploading.

There seems to be so little explanation of this anywhere, that any information at all would be of great help.

  • 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-26T05:41:45+00:00Added an answer on May 26, 2026 at 5:41 am

    .toDataURL returns a base 64 encoded PNG image of the canvas, something like:

    data:image/png;base64,iVBORw0KG...
    

    The base 64 encoded part starts after the comma, i.e. at position 22. So all you need to do is decoding the string, starting from index 22: http://jsfiddle.net/eGjak/187/.

    var decoded = atob(cv.toDataURL().substr(22)); // atob decodes base 64
    
    alert(decoded.length); // length of png file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Canvas method toDataURL, I would like to be able to save the image
I'm using canvas to get image data, and i'm sending that image data to
When you rotate an image using canvas, it'll get cut off - how do
I know I can save the image from canvas using the canvas.toDataURL(). But how
I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i
I'm having trouble roating an image around itself using Canvas. Since you can't rotate
I'm using getImageData / putImageData on a HTML5 canvas to be able to manipulate
I am using Canvas.drawCircle to draw a circle in Android laout. Method gets 3
I am drawing an image in HTML 5 using canvas in JavaScript. I need
I want to manipulate the image data of every frame of an animated gif

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.