TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Image scanned has big size with Python

Forums › TWAIN Classic › Image scanned has big size with Python

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 1 month ago by MarkM.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 27, 2014 at 4:44 pm #22984 Reply
    Mengo
    Participant
    • Topics - 1
    • Replies - 0
    • Total Posts - 1

    I’m trying to scan an image from a scanner with Python.
    I used twain library and it works, but the image size is very big at same dpi. When I scan directly with scanner I have an image of (about) 150kb, and when I scan with my application I have an image of (about) 1.50 mb. Someone could help me?

    I post my simple code:
    import twain
    sm= twain.SourceManager(0)
    ss = sm.OpenSource()
    ss.RequestAcquire(0,0)
    rv = ss.XferImageNatively()
    if rv:
    (handle, count) = rv
    twain.DIBToBMFile(handle,’imageName.jpg’)

    November 20, 2014 at 8:58 pm #26221 Reply
    MarkM
    Participant
    • Topics - 1
    • Replies - 135
    • Total Posts - 136

    Native transfers are always uncompressed images, so your image size will be:
    (width-in-inches * dpi) * (height-in-inches * dpi) * bytes-per-pixel

    Memory, File and MemFile transfers can use compression, like JPEG or Group4, both of which will significantly reduced the size of the image.

    Memory transfers are the only ones all drivers must support (aside from native). In the case of JPEG you will almost certainly get a JFIF header, so the image is complete as-is. In the case of Group4, you’ll have to prefix the image data with a TIFF or a PDF wrapper to get a file that can be rendered by a viewer.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Image scanned has big size with Python
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • Girls of Desire: All babes in one place, crazy, art
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

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.