Quality Save Image don't work

I’m trying to resize an image previous uploaded from form, work great, except by the quality parameter of the “Save Image” proccesor. Set 70 or 15 is the same size of the new file saved, both with same quality.

Example:
Uploading a file of 916kb (1800x1800px) resizing to 500x500px, quality 70, final size 136kb.
Uploading a file of 916kb (1800x1800px) resizing to 500x500px, quality 20, final size 136kb.

Everything work great, each image get saved in propper path, only the quality parameter is the problem.

Thanks

Which server model are you using (ASP, PHP or NodeJS)?

Php
Wappler 4.4.1
Windows

Tested it myself and seems to work fine.


image

Tested with PHP 7.3 with apache in docker. Wappler 4.4.1

Sorry, I can’'t make it works, tested with last php 7.3, 7,4 and 8 over apache and nginx.

image

<?php

require('../../../../../dmxConnectLib/dmxConnect.php');

$app = new \lib\App();

$app->define(<<<'JSON'

{

  "meta": {

    "$_POST": [

      {

        "type": "number",

        "name": "id_evento"

      },

      {

        "type": "text",

        "name": "nombre_evento"

      },

      {

        "type": "text",

        "name": "ruta_imagen"

      },

      {

        "type": "text",

        "name": "descripcion"

      },

      {

        "type": "text",

        "name": "evento_url"

      }

    ]

  },

  "exec": {

    "steps": [

      "SecurityProviders/ses_clientes",

      {

        "name": "",

        "module": "auth",

        "action": "restrict",

        "options": {

          "provider": "ses_clientes",

          "permissions": [

            "admin"

          ],

          "loginUrl": "/",

          "forbiddenUrl": "/"

        }

      },

      {

        "name": "subir_imagen_evento",

        "module": "upload",

        "action": "upload",

        "options": {

          "path": "/imagenes/eventos/highres",

          "fields": "{{$_POST.ruta_imagen}}"

        },

        "meta": [

          {

            "name": "name",

            "type": "text"

          },

          {

            "name": "path",

            "type": "text"

          },

          {

            "name": "url",

            "type": "text"

          },

          {

            "name": "type",

            "type": "text"

          },

          {

            "name": "size",

            "type": "text"

          },

          {

            "name": "error",

            "type": "number"

          }

        ],

        "outputType": "array"

      },

      {

        "name": "image_resize",

        "module": "image",

        "action": "load",

        "options": {

          "path": "{{subir_imagen_evento.url}}"

        },

        "outputType": "object",

        "meta": [

          {

            "name": "width",

            "type": "number"

          },

          {

            "name": "height",

            "type": "number"

          }

        ]

      },

      {

        "name": "imageInfo",

        "module": "image",

        "action": "getImageSize",

        "options": {

          "path": "{{subir_imagen_evento.url}}"

        },

        "outputType": "object",

        "meta": [

          {

            "name": "width",

            "type": "number"

          },

          {

            "name": "height",

            "type": "number"

          }

        ]

      },

      {

        "name": "",

        "module": "core",

        "action": "condition",

        "options": {

          "if": "{{imageInfo.width>500}}",

          "then": {

            "steps": [

              {

                "name": "",

                "module": "image",

                "action": "resize",

                "options": {

                  "instance": "image_resize",

                  "width": 500,

                  "height": 500

                }

              },

              {

                "name": "newImage",

                "module": "image",

                "action": "save",

                "options": {

                  "instance": "image_resize",

                  "path": "/imagenes/eventos/lowres",

                  "template": "{name}_lowres75{ext}"

                }

              },

              {

                "name": "newImage_copy",

                "module": "image",

                "action": "save",

                "options": {

                  "instance": "image_resize",

                  "quality": 20,

                  "path": "/imagenes/eventos/lowres",

                  "template": "{name}_lowres20{ext}"

                }

              },

              {

                "name": "",

                "module": "core",

                "action": "condition",

                "options": {

                  "if": "{{newImage}}",

                  "then": {

                    "steps": {

                      "name": "actualizar_ultimo_evento",

                      "module": "dbupdater",

                      "action": "insert",

                      "options": {

                        "connection": "db_main",

                        "sql": {

                          "type": "insert",

                          "values": [

                            {

                              "table": "main_eventos",

                              "column": "id_evento",

                              "type": "number",

                              "value": "{{$_POST.id_evento}}"

                            },

                            {

                              "table": "main_eventos",

                              "column": "nombre_evento",

                              "type": "text",

                              "value": "{{$_POST.nombre_evento}}"

                            },

                            {

                              "table": "main_eventos",

                              "column": "ruta_imagen",

                              "type": "text",

                              "value": "{{newImage}}"

                            },

                            {

                              "table": "main_eventos",

                              "column": "descripcion",

                              "type": "text",

                              "value": "{{$_POST.descripcion}}"

                            },

                            {

                              "table": "main_eventos",

                              "column": "evento_url",

                              "type": "text",

                              "value": "{{$_POST.evento_url}}"

                            }

                          ],

                          "table": "main_eventos",

                          "returning": "id",

                          "query": "INSERT INTO main_eventos\n(id_evento, nombre_evento, ruta_imagen, descripcion, evento_url) VALUES (:P1 /* {{$_POST.id_evento}} */, :P2 /* {{$_POST.nombre_evento}} */, :P3 /* {{newImage}} */, :P4 /* {{$_POST.descripcion}} */, :P5 /* {{$_POST.evento_url}} */)",

                          "params": [

                            {

                              "name": ":P1",

                              "type": "expression",

                              "value": "{{$_POST.id_evento}}"

                            },

                            {

                              "name": ":P2",

                              "type": "expression",

                              "value": "{{$_POST.nombre_evento}}"

                            },

                            {

                              "name": ":P3",

                              "type": "expression",

                              "value": "{{newImage}}"

                            },

                            {

                              "name": ":P4",

                              "type": "expression",

                              "value": "{{$_POST.descripcion}}"

                            },

                            {

                              "name": ":P5",

                              "type": "expression",

                              "value": "{{$_POST.evento_url}}"

                            }

                          ]

                        }

                      },

                      "meta": [

                        {

                          "name": "identity",

                          "type": "text"

                        },

                        {

                          "name": "affected",

                          "type": "number"

                        }

                      ]

                    }

                  }

                },

                "outputType": "boolean"

              }

            ]

          }

        },

        "outputType": "boolean"

      }

    ]

  }

}

JSON

);

?>

This are the output save files:

image

Even I have re-upload the whole directory to server deleting first everything in there.

What I can do to debug this.
Thanks

What are you saving? png images do not have a quality option, only with jpeg you can set the quality.

My big mistake, sorry for that. I really spend more time in this forum than social networks, and I Love it, the hurry to fix this I forgot my the basic design web rules about image format. :slight_smile:

1 Like

Apache, Debian 10, Wappler Windows 4.4.5.
libpng 1.6.36 (lastest version available for debian buster)

Hi,
I have a new problem:
I get this message when I upload a png file (with interlace option on).

1. code: 0
2. file: "/xxx/xxxx/xxxxx/dmxConnectLib/lib/image/Processor.php"
3. line: 29
4. message: "imagecreatefromstring(): gd-png: libpng warning: Interlace handling should be turned on when using png_read_image"

This is in server actions:
image

If I upload a png file with interlace option to none from any graphics software the image get proccess correctly.

Another thing is that If I upload a jpg file it gets compress perfectly with the quality set before in server actions. Jpg have not problems. But I don’t understand why this options if I upload a png file it do not get converted in jpg for example, for what is this option? Or “Save Image” server action do not convert file and maybe is just to select the same format of image that it being uploaded?

image

Thanks in advance.

Well it seems you are uploading a png image and try to resize it to jpeg but the png support on your php server is off.

You should make sure png is enabled in gd for php.

Yes, my server has enable gd and libpng. Is a VPS.

Could you run phpinfo() and show the output?

I think that it is a bug in libPNG.

php - imagecreatefrompng(): gd-png: libpng warning: Interlace handling should be turned on when using png_read_image - Stack Overflow

1121035 – libpng warning: Interlace handling should be turned on when using png_read_image (redhat.com)