‎2011 Jul 08 10:21 PM
Hi all,
I am uploading a JPG image file in GUI and I need to validate its dimension. Is there any function module that I can use to get the width and height?
Thanks.
‎2011 Jul 09 2:07 PM
Hi Felipe,
I don't know any function module or class method for this - though it may exist.
As I just found out, JPEG structure is (in most cases) pretty simple. The JPEG files contains some identifiers starting a defined structure.
Put the uploaded JPEG into an XSTRING field, search for start-of-frame 0 identifier followed by lenght and data precision constant 'FFC0001108'. This constant is followed by two unsigned integers for height and width. If you found this offset, assign xstringoffset(2) to shortint height variable, add 2 to offset and assign xstringoffset(2) to shortint width variable.
As we do not have 2-byte unsigned integers we will move the first byte to an INT1 variable Hbyte, second byte to INT1 variable Lbyte and get the result as Hbyte * 256 + Lbyte.
I found information on [Getting JPG dimensions with AS3 without loading the entire file|http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/] in non-ABAP language. Give it a try.
Regards,
Clemens
‎2011 Jul 09 2:07 PM
Hi Felipe,
I don't know any function module or class method for this - though it may exist.
As I just found out, JPEG structure is (in most cases) pretty simple. The JPEG files contains some identifiers starting a defined structure.
Put the uploaded JPEG into an XSTRING field, search for start-of-frame 0 identifier followed by lenght and data precision constant 'FFC0001108'. This constant is followed by two unsigned integers for height and width. If you found this offset, assign xstringoffset(2) to shortint height variable, add 2 to offset and assign xstringoffset(2) to shortint width variable.
As we do not have 2-byte unsigned integers we will move the first byte to an INT1 variable Hbyte, second byte to INT1 variable Lbyte and get the result as Hbyte * 256 + Lbyte.
I found information on [Getting JPG dimensions with AS3 without loading the entire file|http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/] in non-ABAP language. Give it a try.
Regards,
Clemens
‎2011 Jul 11 3:40 PM
solved, Thanks Clemens
Edited by: Felipe Grajales on Jul 11, 2011 4:41 PM
‎2011 Jul 09 3:15 PM
Hi,
I think you can use IGS (depending on your SAP release). IMGCONV tool can be reached through CL_IGS_IMAGE_CONVERTER, where you can get attributes HEIGHT and WIDTH. To be tested.
More info: http://help.sap.com/saphelp_nw70/helpdata/en/17/86c039c7811f11e10000000a114084/frameset.htm
Search SDN too.
BR
Sandra
‎2021 Mar 12 4:03 PM
Check this code snippet. Not tested on all picture formats, but jp(e)g works well.
Under hood works the IGS, but this nice encapsulation does the job.
DATA:
mimetype TYPE string,
xres TYPE i,
yres TYPE i,
xdpi TYPE i,
ydpi TYPE i,
bitdepth TYPE i,
image_processor TYPE REF TO cl_fxs_image_processor.
image_processor = NEW #( ).
DATA(handle) = image_processor->add_image_from_url( iv_url = '<real url pointing to an image>').
image_processor->get_info( EXPORTING iv_handle = handle
IMPORTING ev_mimetype = mimetype
ev_xres = xres
ev_yres = yres
ev_xdpi = xdpi
ev_ydpi = ydpi
ev_bitdepth = bitdepth ).