Resize/Crop jpeg image

Posted on 2004-11-03
Last Modified: 2013-11-17
I have a TImage that uses LoadFromFile() to load a jpeg image.
I have a method for checking the size of the image (e.g. max 640x480) and want to change the the image size to the max size and then use SaveToFile() to save that image again.
The reason for this is to make the filesize smaller when sending via email or internet.

Any help would be grealy appreciated!

Question by:Balder1978
    LVL 16

    Expert Comment

    by:George Tokas
    Check out TImage::Stretch property at online help..
    I think is what you need...

    LVL 45

    Expert Comment


    Assuming that you're using a TJPEGImage, you can save a bunch more space by reducing the value in the CompressionQuality property.

    LVL 4

    Expert Comment

    First, if you want to reduce the file size , you should reduce image size , not increase it.

    to change a jpeg image size , you can create a bitmap object , and set it's height and width to your desired size , and then use draw() method to draw the jpeg image in bitmap object, then again draw it to a jpeg image and save it to a file.
    LVL 2

    Author Comment

    I'm using Borland C++ 4 and I don't have the TJPEGImage compnent available, I'm using TImage.

    Yes, reduce the size. If the size is larger than 640x480 then it should reduce the size to 640x480.

    I'll check out the drawing thingy, thanks.
    LVL 4

    Accepted Solution

    sorry, you should use stretchdraw not draw.
    LVL 2

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now