#88 Massively improved JPEG Transform

None
closed
None
5
2014-08-20
2014-02-27
No

Attached is a heavily modified JPEGTransfrom that adds the flowing improvements:

  • Operate on FreeImageIO and FIMEMORY
  • Support Transform and Crop in one operation
  • Returns the exact output image bounds, adjusted after transformation is applied
  • Support for querying the output bounds, without actually performing the transformation
  • Support of negative right and bottom bounds, which will be counted from the width and height inwards

To compile, except the attached JPEGTransfrom.cpp file

Add in Utilities.h:

void jpeg_freeimage_src (struct jpeg_decompress_struct* cinfo, fi_handle infile, struct FreeImageIO *io);

void jpeg_freeimage_dst (struct jpeg_compress_struct* cinfo, fi_handle outfile, struct FreeImageIO *io);

To use the new staff
Add in FreeImage.h:

DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* srcIO, fi_handle src_handle, FreeImageIO* dstIO, fi_handle dst_handle, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect);

DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect);

DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect);

DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect);

Usage

  • Input bounds are relative to the resulting image size (width and height are swapped on transpose, transverse, 90, 270 rotations)
  • To crop specified amount from the side or bottom of the image use negative right and bottom
  • To query output bounds without performing a crop use all zeros as crop input
  • To query output bounds without performing any transformations use NULL as dest "file"
1 Attachments

Discussion

  • Hervé Drolon

    Hervé Drolon - 2014-03-16
    • status: open --> accepted
    • assigned_to: Hervé Drolon
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2014-03-16

    Hi Mihail,

    Many thanks for this patch, it is now available in the CVS.

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2014-03-23

    fixed in release 3.16.0

     
  • Hervé Drolon

    Hervé Drolon - 2014-03-23
    • status: accepted --> closed
     
  • Mihail Naydenov

    Mihail Naydenov - 2014-07-30

    There is an embarrassing error.
    closeStdIO in JPEGTransform.cpp must check if not closing the same handle twice!
    This happens if one alters an image in-place (used as src and dst) and leads to crash on linux with "double free" error. (Oddly on Windows its fine...)

    Quick fix: Line 379 changed to:
    if(dst_handle && dst_handle != src_handle) {

     
  • Hervé Drolon

    Hervé Drolon - 2014-07-30

    Hi Mihail,

    Is it a quick fix or a definitive fix ?

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2014-07-30

    OK,

    After examination, the quick fix is a GOOD fix anyway - commited to the CVS.

    Hervé

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks