2021 Oct 11 2:42 PM
hey all
I use class cl_fxs_image_processor to resize some png-files in my system. But I've a problem with pictures in portrait mode.
Example:
Picture has a height of 4624px and a width of 2084px
But cl_fxs_image_processor=>get_info states xres = 4624 and yres = 2048 which isn't correct... as a consequence the resized picture is mailed rotated...
How can I get the right information of my XSTRING-Picture?
Or can I get EXIF-information out of the xstring to change X and y myself?
Any other hints?
importing if_original type xstringval
returning rf_small type xtringval
METHOD resize4mail.
TRY.
DATA(lo_image) = NEW cl_fxs_image_processor( ).
DATA(lf_handle) = lo_image->add_image( if_original ).
lo_image->get_info(
EXPORTING
iv_handle = lf_handle
IMPORTING
ev_xres = DATA(lf_xres)
ev_yres = DATA(lf_yres) ).
"Neue Höhe berechnen... Verhältnis beibehalten
DATA(lf_ratio) = lf_xres / lf_yres.
DATA(lf_xres_new) = cc_xres_mail. "1024
IF lf_xres_new >= lf_xres.
rf_small = if_original.
lo_image->discard_image( lf_handle ).
FREE lo_image.
RETURN.
ENDIF.
DATA(lf_yres_new) = lf_xres_new / lf_ratio.
lo_image->resize(
EXPORTING
iv_handle = lf_handle
iv_xres = lf_xres_new
iv_yres = lf_yres_new ).
rf_small = lo_image->get_image( lf_handle ).
lo_image->discard_image( lf_handle ).
FREE lo_image.
CATCH cx_root.
ASSERT 1 = 2.
ENDTRY.
ENDMETHOD.
Regards,
Daniel
hey all
I use class cl_fxs_image_processor to resize some png-files in my system. But I've a problem with pictures in portrait mode.
Example:
Picture has a height of 4624px and a width of 2084px
But cl_fxs_image_processor=>get_info states xres = 4624 and yres = 2048 which isn't correct... as a consequence the resized picture is mailed rotated...
How can I get the right information of my XSTRING-Picture?
Or can I get EXIF-information out of the xstring to change X and y myself?
Any other hints?
importing if_original type xstringval
returning rf_small type xtringval
METHOD resize4mail.
TRY.
DATA(lo_image) = NEW cl_fxs_image_processor( ).
DATA(lf_handle) = lo_image->add_image( if_original ).
lo_image->get_info(
EXPORTING
iv_handle = lf_handle
IMPORTING
ev_xres = DATA(lf_xres)
ev_yres = DATA(lf_yres) ).
"Neue Höhe berechnen... Verhältnis beibehalten
DATA(lf_ratio) = lf_xres / lf_yres.
DATA(lf_xres_new) = cc_xres_mail. "1024
IF lf_xres_new >= lf_xres.
rf_small = if_original.
lo_image->discard_image( lf_handle ).
FREE lo_image.
RETURN.
ENDIF.
DATA(lf_yres_new) = lf_xres_new / lf_ratio.
lo_image->resize(
EXPORTING
iv_handle = lf_handle
iv_xres = lf_xres_new
iv_yres = lf_yres_new ).
rf_small = lo_image->get_image( lf_handle ).
lo_image->discard_image( lf_handle ).
FREE lo_image.
CATCH cx_root.
ASSERT 1 = 2.
ENDTRY.
ENDMETHOD.
Regards,
Daniel
2021 Oct 11 2:51 PM
No problem for me with portrait image, I get correctly x=529, y=849.
2021 Oct 11 3:05 PM
yes i know... very strange.
The pics are taken by mobile phone and uploaded via an Fiori App. If I display the same picture also on an app, it isn't rotated. If I send the mail without resizing it, it isn't rotated... just if I call method get_info the values are switched and the picture is rotated after resizing it.
2021 Oct 11 3:08 PM
I have used it here, and no problem with all image. Code is little bit long & protected to publish it
but looks like your
METHOD convertit_taille_image.
DATA(lv_nouvelle_taille_x) = get_taille_x_image( iv_image_id ) / iv_facteur_conversion.
DATA(lv_nouvelle_taille_y) = get_taille_y_image( iv_image_id ) / iv_facteur_conversion.
TRY.
go_image_processor->resize( iv_handle = iv_image_id
iv_xres = CONV i( lv_nouvelle_taille_x )
iv_yres = CONV i( lv_nouvelle_taille_y ) ).
CATCH cx_sy_range_out_of_bounds .
rv_image_data = go_image_processor->get_image( iv_image_id ).
ENDTRY.
rv_image_data = go_image_processor->get_image( iv_image_id ).
ENDMETHOD.
with french comment, it works better 😉
2021 Oct 20 7:10 AM
Unfortunately, the issue is known. The class is obsolete.
Hello Daniel,
regarding the problem of the lost orientiation of the image: this problem happens when using CL_FXS_IMAGE_PROCESSOR->ADD_IMAGE() as well as with method ->RESIZE().
1. Method ADD_IMAGE()
With the call of method ADD_IMAGE() the metadata (width, height, color depth) are read from the JPEG marker'SOF' in the image file. The orientation of the image is not part of that JPEG marker. The orientation of the image are part of the EXIF meta data but these are ignored and get lost when an image is 'added' with method ADD_IMAGE()
2. Method RESIZE()
Resizing is based on the IGS(Internet Graphics Service). This uses internally the libjpeg library which itself doesn't support EXIF data in the version which is used by IGS. So during scaling the EXIF data are removed completely from the image.
Unfortunately IGS is also a very old component and will not be updated.
Regarding the support of package S_XSLFO: the features of packages S_XSLFO* and S_XSL_FO* was never released for external development. Both packages were part of a bigger project of which the development was stopped many years ago. Unfortunately this was not communicated well and therefore we released SAP note
https://launchpad.support.sap.com/#/notes/3073421
to describe the current support for the different OOXML packages. For compatibility reasons we were also not able to fully rearrange the different packages to S_OOXML_DEPRECATED because such changes would lead to warnings/errors in our QA systems because the affected releases were shipped already. So as of SAP_BASIS release 753 the package S_XSLFO is also part of S_OOXML_DEPRECATED.
Best regards,
SAP Development Support
And theres no supported api to resize pictures:
Hello Daniel,
unfortunately we are not aware of any supported ABAP API for resizing images or other image processing functionality. So we are sorry but we cannot give you a solution.
Best regards,
SAP Development Support
So... if someone has an idea... I would be happy 🙂
2021 Oct 20 7:22 AM
external tool like Image Magick https://imagemagick.org/index.php
2022 Feb 10 12:09 PM
I believe your only option is to work around the problem.
Girods suggestion (Image Magick) only works if you have a on-premise sap system.
We solved this problem by resizing the image in our SAP UI5 Application with canvas.
Depending on your use-case you might want to check if you can resize the image with css in your email.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |