Image Optimizer for XF 2.0

Image Optimizer for XF 2.0 [Paid] 2.1.8

No permission to buy ($29.00)
Well, I installed all the dependent binaries but I'm dumb. How do I find the path to:

  • pngquant 3.0.0
  • jpegoptim 1.5.1
  • gifsicle 1.93

In order to enter them into the plugin options?
 
for which pngquant I get this:
Code:
/usr/bin/which: no pngquant in (/usr/local/cpanel/3rdparty/lib/path-bin:/usr/share/Modules/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/root/bin)

I installed using:
git clone --recursive https://github.com/kornelski/pngquant.git
cd pngquant
cargo build --release

It installed and built so I'm confused.
 
for which pngquant I get this:
Code:
/usr/bin/which: no pngquant in (/usr/local/cpanel/3rdparty/lib/path-bin:/usr/share/Modules/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/root/bin)

I installed using:
git clone --recursive https://github.com/kornelski/pngquant.git
cd pngquant
cargo build --release

It installed and built so I'm confused.

I use these options on my cPanel server:

/bin/pngquant
/bin/jpegoptim
/bin/gifsicle
 
I verified that all the requirements worked and enabled optimization. Two questions:

1. I've got pages of attachments that show 0 in original size and 0 in optimized size. Is that normal?
2. I could see no setting in Rebuild Caches or elsewhere to run this on all attachments. Is it just running now because I enabled optimization and clicked save in the Options?
 
Hello,
I have installed everything but getting error when trying to verify file path.
Here are few screenshots:

All files are installed: pngquant, jpegoptim, and gifsicle in "/src/addons/Truonglv/ImageOptimizer/"

Screenshot 2023-09-23 at 8.55.26 AM.webp

When I'm entering pngquant path: /src/addons/Truonglv/ImageOptimizer/pngquant
Getting this error:
"ErrorException: [E_WARNING] file_exists(): open_basedir restriction in effect. File(/src/addons/Truonglv/ImageOptimizer/pngquant) is not within the allowed path(s): (/home/technofi/:/tmp:/var/tmp:/opt/alt/php81/usr/share/pear/:/dev/urandom:/usr/local/lib/php/:/usr/local/php81/lib/php/) in src/addons/Truonglv/ImageOptimizer/Repository/Log.php at line 247"
same goes for jpegoptim, and gifsicle.

Screenshot 2023-09-23 at 8.54.31 AM.webp


Any help?
@truonglv
 
Hello,
I have installed everything but getting error when trying to verify file path.
Here are few screenshots:

All files are installed: pngquant, jpegoptim, and gifsicle in "/src/addons/Truonglv/ImageOptimizer/"

View attachment 291455

When I'm entering pngquant path: /src/addons/Truonglv/ImageOptimizer/pngquant
Getting this error:
"ErrorException: [E_WARNING] file_exists(): open_basedir restriction in effect. File(/src/addons/Truonglv/ImageOptimizer/pngquant) is not within the allowed path(s): (/home/technofi/:/tmp:/var/tmp:/opt/alt/php81/usr/share/pear/:/dev/urandom:/usr/local/lib/php/:/usr/local/php81/lib/php/) in src/addons/Truonglv/ImageOptimizer/Repository/Log.php at line 247"
same goes for jpegoptim, and gifsicle.

View attachment 291456


Any help?
@truonglv
It's not recommended to save binary files at that path; in the add-on upgrade steps it may be removed
 
For some reason, it cannot optimize some GIF images, like the one attached.

PHP:
Server error log

LogicException: Failed to optimize image src/addons/Truonglv/ImageOptimizer/XF/Admin/Controller/Tools.php:202
Generated by: Admin Oct 3, 2023 at 1:32 AM

Stack trace
#0 src/XF/Mvc/Dispatcher.php(352): Truonglv\ImageOptimizer\XF\Admin\Controller\Tools->actionIOTest(Object(XF\Mvc\ParameterBag))
#1 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'IoTest', Object(XF\Mvc\RouteMatch), Object(Truonglv\ImageOptimizer\XF\Admin\Controller\Tools), NULL)
#2 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Truonglv\ImageOptimizer\XF\Admin\Controller\Tools), NULL)
#3 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#4 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#5 src/XF.php(524): XF\App->run()
#6 admin.php(13): XF::runApp('XF\\Admin\\App')
#7 {main}

Request state
array(4) {
  ["url"] => string(24) "/admin.php?tools/io-test"
  ["referrer"] => string(44) "https://xf2.com/admin.php?tools/io-test"
  ["_GET"] => array(1) {
    ["tools/io-test"] => string(0) ""
  }
  ["_POST"] => array(1) {
    ["_xfToken"] => string(8) "********"
  }
}
 

Attachments

  • giphy (2).gif
    giphy (2).gif
    3.5 MB · Views: 21
Has anyone been able to get pngquant to build on CentOS7 since the move to rust and cargo? I've got the addon running with the OS installed version, but pngquant3 won't build

Code:
[root@da pngquant]# cargo build --release
   Compiling pngquant v3.0.3 (/root/pngquant)
The following warnings were emitted during compilation:

warning: rwpng.c: In function ‘rwpng_create_row_pointers’:
warning: rwpng.c:126:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:      for(size_t row = 0; row < height; row++) {
warning:      ^
warning: rwpng.c:126:5: note: use option -std=c99 or -std=gnu99 to compile your code
warning: rwpng.c: In function ‘rwpng_read_image24_libpng’:
warning: rwpng.c:389:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:          for (unsigned int i = 0; i < mainprog_ptr->height; i++) {
warning:          ^
warning: rwpng.c: In function ‘rwpng_write_image8’:
warning: rwpng.c:589:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:      for(unsigned int i = 0; i < mainprog_ptr->num_palette; i++) {
warning:      ^
warning: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/rwpng.o" "-c" "rwpng.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/pngquant.o" "-c" "pngquant.c"
warning: pngquant.c: In function ‘pngquant_main_internal’:
warning: pngquant.c:343:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:          for(unsigned int i=0; i < pal->count; i++) {
warning:          ^
warning: pngquant.c:343:9: note: use option -std=c99 or -std=gnu99 to compile your code
warning: pngquant.c:364:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:      for(int i=0; i < options->num_files; i++) {
warning:      ^
warning: pngquant.c: In function ‘set_palette’:
warning: pngquant.c:546:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:      for(unsigned int i=0; i < palette->count; i++) {
warning:      ^
warning: pngquant.c: In function ‘prepare_output_image’:
warning: pngquant.c:749:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
warning:      for(size_t row = 0; row < output_image->height; row++) {
warning:      ^
warning: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/pngquant.o" "-c" "pngquant.c" with args "cc" did not execute successfully (status code exit status: 1).

error: failed to run custom build command for `pngquant v3.0.3 (/root/pngquant)`

Caused by:
  process didn't exit successfully: `/root/pngquant/target/release/build/pngquant-d0deac52fd15e94f/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/rwpng.o" "-c" "rwpng.c"
  cargo:warning=rwpng.c: In function ‘rwpng_create_row_pointers’:

  cargo:warning=rwpng.c:126:5: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=     for(size_t row = 0; row < height; row++) {

  cargo:warning=     ^

  cargo:warning=rwpng.c:126:5: note: use option -std=c99 or -std=gnu99 to compile your code

  cargo:warning=rwpng.c: In function ‘rwpng_read_image24_libpng’:

  cargo:warning=rwpng.c:389:9: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=         for (unsigned int i = 0; i < mainprog_ptr->height; i++) {

  cargo:warning=         ^

  cargo:warning=rwpng.c: In function ‘rwpng_write_image8’:

  cargo:warning=rwpng.c:589:5: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=     for(unsigned int i = 0; i < mainprog_ptr->num_palette; i++) {

  cargo:warning=     ^

  exit status: 1
  cargo:warning=ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/rwpng.o" "-c" "rwpng.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/pngquant.o" "-c" "pngquant.c"
  cargo:warning=pngquant.c: In function ‘pngquant_main_internal’:

  cargo:warning=pngquant.c:343:9: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=         for(unsigned int i=0; i < pal->count; i++) {

  cargo:warning=         ^

  cargo:warning=pngquant.c:343:9: note: use option -std=c99 or -std=gnu99 to compile your code

  cargo:warning=pngquant.c:364:5: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=     for(int i=0; i < options->num_files; i++) {

  cargo:warning=     ^

  cargo:warning=pngquant.c: In function ‘set_palette’:

  cargo:warning=pngquant.c:546:5: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=     for(unsigned int i=0; i < palette->count; i++) {

  cargo:warning=     ^

  cargo:warning=pngquant.c: In function ‘prepare_output_image’:

  cargo:warning=pngquant.c:749:5: error: ‘for’ loop initial declarations are only allowed in C99 mode

  cargo:warning=     for(size_t row = 0; row < output_image->height; row++) {

  cargo:warning=     ^


  exit status: 1
  cargo:warning=ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/pngquant.o" "-c" "pngquant.c" with args "cc" did not execute successfully (status code exit status: 1).

  --- stderr


  error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lcms2-sys-4.0.3/vendor/include" "-I" "/root/pngquant/lib/imagequant-sys" "-I" "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpng-sys-1.1.9/vendor" "-I" "/root/pngquant/target/release/build/libz-sys-ac3297b20e9c7804/out/include" "-I" "/root/pngquant/target/release/build/libpng-sys-e6d8e846bde50a87/out" "-DPNGQUANT_NO_MAIN=1" "-DUSE_LCMS=1" "-DNDEBUG=1" "-DUSE_SSE=1" "-o" "/root/pngquant/target/release/build/pngquant-0f0ff12c9ac8ff37/out/pngquant.o" "-c" "pngquant.c" with args "cc" did not execute successfully (status code exit status: 1).
 
I've been able to build it now on a CentOS7 box, and export it over to the server in question. I had to use a newer GCC version

Code:
   40  yum install -y centos-release-scl
   41  yum install -y devtoolset-7
   42  scl enable devtoolset-7 bash

Code:
[root@da ~]# which gcc
/opt/rh/devtoolset-7/root/usr/bin/gcc
[root@da ~]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and then build it in there
Code:
[root@da pngquant]# cargo build --release
    Updating crates.io index
   Compiling libc v0.2.150
   Compiling jobserver v0.1.27
   Compiling cc v1.0.83
   Compiling autocfg v1.1.0
   Compiling pkg-config v0.3.27
   Compiling memoffset v0.9.0
   Compiling cfg-if v1.0.0
   Compiling dunce v1.0.4
   Compiling crossbeam-utils v0.8.16
   Compiling crossbeam-epoch v0.9.15
   Compiling vcpkg v0.2.15
   Compiling scopeguard v1.2.0
   Compiling libz-sys v1.1.12
   Compiling rayon-core v1.12.0
   Compiling crossbeam-deque v0.8.3
   Compiling lcms2-sys v4.0.3
   Compiling libpng-sys v1.1.9
   Compiling imagequant-sys v4.0.3 (/root/pngquant/lib/imagequant-sys)
   Compiling bytemuck v1.14.0
   Compiling once_cell v1.18.0
   Compiling either v1.9.0
   Compiling rayon v1.8.0
   Compiling thread_local v1.1.7
   Compiling rgb v0.8.37
   Compiling arrayvec v0.7.4
   Compiling imagequant v4.2.2 (/root/pngquant/lib)
   Compiling pngquant v3.0.3 (/root/pngquant)
   Compiling unicode-width v0.1.11
   Compiling bitflags v2.4.1
   Compiling getopts v0.2.21
   Compiling wild v2.2.0
    Finished release [optimized] target(s) in 36.94s
 
For some reason, it cannot optimize some GIF images, like the one attached.

PHP:
Server error log

LogicException: Failed to optimize image src/addons/Truonglv/ImageOptimizer/XF/Admin/Controller/Tools.php:202
Generated by: Admin Oct 3, 2023 at 1:32 AM

Stack trace
#0 src/XF/Mvc/Dispatcher.php(352): Truonglv\ImageOptimizer\XF\Admin\Controller\Tools->actionIOTest(Object(XF\Mvc\ParameterBag))
#1 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'IoTest', Object(XF\Mvc\RouteMatch), Object(Truonglv\ImageOptimizer\XF\Admin\Controller\Tools), NULL)
#2 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Truonglv\ImageOptimizer\XF\Admin\Controller\Tools), NULL)
#3 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#4 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#5 src/XF.php(524): XF\App->run()
#6 admin.php(13): XF::runApp('XF\\Admin\\App')
#7 {main}

Request state
array(4) {
  ["url"] => string(24) "/admin.php?tools/io-test"
  ["referrer"] => string(44) "https://xf2.com/admin.php?tools/io-test"
  ["_GET"] => array(1) {
    ["tools/io-test"] => string(0) ""
  }
  ["_POST"] => array(1) {
    ["_xfToken"] => string(8) "********"
  }
}

Have you found a solution?
 
Top Bottom