Git Product home page Git Product logo

pthumb's Introduction

pThumb 2.3.1-pl

A fork of phpThumbOf 1.4.0. pThumb is a lightweight, efficient, and actively maintained replacement for phpThumbOf. It offers most of the functionality of its predecessor while adding new features, fixing bugs, and offering some potentially dramatic speed improvements on sites which use phpThumbOf heavily.

Curious how pThumb compares to phpThumbsUp, etc.? I’ve got a wiki page with some observations and thoughts. There are a few other worthwhile pages there too.

Вопросы? Проблемы? Пишите по-русски!

Installation

pThumb is a drop-in replacement for phpThumbOf. It uses the same namespace, settings and component names, so after it's installed any code using phpThumbOf will automatically use the new version instead, with no further changes to the site required.

  1. Download pThumb via Package Management.
  2. Uninstall phpThumbOf if it's installed.
  3. Install pThumb.

Your phpThumbOf cache will be cleared in the process, but since pThumb generates slightly different filenames the images would have to be regenerated anyway.

(Actually you don't have to uninstall phpThumbOf first, but it makes things less confusing. If you uninstall phpThumbOf later, you'll have to reinstall pThumb.)

Documentation

pThumb includes two snippets: phpthumbof and pthumb. They're exactly the same; use whichever snippet name you like best. phpthumbof is handy for an existing site that was already using phpthumbof; pthumb better for future compatibility and shorter too :-)

Official documentation for phpThumbOf and phpThumb.

pThumb adds the following system settings:

  • Check File Modification Time: Checks the original image's file modification time and updates the cached version if necessary. Changing this setting's value will cause all currently cached images to become stale. Default: No

  • Global Defaults: An options string of global defaults. For example: q=60&zc=C. These may be overridden by specifying another value in the snippet call.

  • Use Resizer: A global setting for which image manipulation class to use. Setting this to No means pThumb will use the MODX's built-in phpThumb class. See the Resizer section and extra for more details. Default: No

  • Use pThumb Cache: Controls which cache system to use: the ”classic” phpThumbOf cache or the new pThumb cache which supports subdirectories and uses shorter hashes. See the section below for more on this. Default: No

  • Clean Level: Specifies what the cache manager plugin should do on site refresh (site cache clear) events. The plugin processes all 3 caches: phpThumbOf style, pThumb style, and remote images. Possible values — 0: (default) Do nothing. || 1: Clean the caches separately based on the “Max Cache *” system settings (core > phpThumb). || 2: Delete all cached images. || One tip for option 1: changing one of the “Max Cache *” settings to 0 will disable cache cleaning for that parameter.

and several new properties to the phpthumbof/pthumb snippets:

  • &debug: When this is on, phpThumbOf will write the phpThumb debugmessages array to the MODX error log. This is very useful for troubleshooting phpThumb issues, like whether it's using ImageMagick on not.

  • &useResizer: Overrides the phpthumbof.use_resizer system setting to allow more flexibility in switching between phpThumb and Resizer. Useful if you generally want to use one but need the other in a few particular places.

  • &toPlaceholder: Stores the output in three placeholders: thumbnail URL, width and height. Ex: [[pthumb? &input=`[[*imagetv]]` &options=`w=200` &toPlaceholder=`thumb`]] then <img src="[[+thumb]]" width="[[+thumb.width]]" height="[[+thumb.height]]">. For more details on this see the Image Dimensions section.

  • &s3output, &s3multiImg: See the S3 documentation.

New pThumb Features

Resizer

[Requires PHP 5.3 or higher]

pThumb comes bundled with Resizer, a lightweight modern alternative to phpThumb. Built on Imagine, Resizer supports the Gmagick, Imagick and GD extensions and is considerably faster than phpThumb for image sizing and cropping operations. Plus all the ZC options now work with GD.

See the Resizer documentation for more on its requirements and supported options. Note that it doesn’t support any of phpThumb’s filters, but many of these things can be done with CSS nowadays.

To enable it, go to System Settings and under phpthumbof, change Use Resizer to Yes. You don't need to make any other changes to your site; pThumb transparently handles switching between them. You can even override the system setting for a particular pthumb call by using the &useResizer property (1 for yes, 0 for no).

pThumb Cache

New in version 2.1 is the pThumb Cache, an option which allows cleaner, more semantic and SEO-friendly URLs. Instead of everything being lumped into a one-level directory and having a 32-character hash appended, the new cache system stores thumbnails in subdirectories which mirror part of the original image's path and adds only an 8-character hash to filenames. Plus, pThumb still offers the original phpThumbOf-style cache. You switch between the two via a system setting.

Cache operation is controlled by three settings (in System Settings under phpthumbof):

  • pThumb Cache Location: The directory to store cached images. The path is relative to the MODX base directory, which is generally your web root. It defaults to assets/image-cache. pThumb will create this directory if it doesn't already exist (as long as filesystem permissions allow it to).

  • Images Base Directory: This should be set to the directory where you have your images. It defaults to assets, but you'll probably want to make it more specific. This directory and any above it will be left out of the cache filename's path. Any subdirectories below it will be included. See the example below for more details. If you run pThumb on an image outside this directory, it'll simply be put in the top level of the cache.

  • Use pThumb Cache: Once you've checked the above two settings, flip this to Yes to switch to use the new cache.

Example: You've set up a media source for all the content images on your site and they're all in assets/acme/images/ Use that for the Image Base Directory setting. Leading/trailing slashes don't matter; pThumb will deal with them either way. You leave Cache Location set to the default. First you call pthumb on this image: assets/acme/images/products/whiz-o-matic/exploded-view-1.jpg. To create a cache filename your Image Base Directory value—and anything in front of it—will be replaced with Cache Location and the rest of the path used for the name, meaning you'll end up with a thumbnail URL of /assets/image-cache/products/whiz-o-matic/exploded-view-1.a9b0032f.jpg. Now suppose you've got some oddball image in assets/misc/clutter/junky-junk.jpg (that is, outside the Image Base Directory you set). No problem, it'll just go to assets/image-cache/junky-junk.922ebc0b.jpg.

Note: Switching cache systems won't migrate your cached images from one cache to the other; images be regenerated as needed. But it won't delete existing images either, so if you switch back they'll still be there.

Amazon S3

Version 2.3 adds S3 support, with some improvements over phpThumbOf. See this page for instructions on how to use it.

Remote Images

pThumb goes to some lengths to handle remote images well, whether they’re coming from an S3 media source or from some other server. It uses cURL to download the original image to assets/components/phpthumbof/cache/remote-images/, then uses that local copy for all future operations, meaning things are quite fast after the first run. Version 2.3 improves file naming for remote images, so the output thumbnail file names will be the same as if the original images were local.

Be aware though that once the remote image has been cached, pThumb won't look at the original again unless you delete the cached copy. Or as an alternative, you may use a query parameter for cache busting. For example if you have a TV called someImageTV, you can do something like this: <img src="[[pthumb? &input=`[[*someImageTV]]?v=1` &options=`h=150&w=150`]]">. The first time through this will cause pThumb to download a new copy of the remote image and generate a new thumbnail.

Image Dimensions

Starting in version 2.3.1 pThumb can also output image dimensions. It provides two ways of doing this. The first is the &toPlaceholder property described above. Sometimes though placeholders can be tricky, like when they’re being used in a chunk being iterated over by something like getResources. In certain cases—if you don’t give the placeholders distinct names like &toPlaceholder=`img[[+idx]]`—all the placeholders will be filled in with the values from the last iteration.

However there’s another way to get image dimensions which doesn’t involve placeholders: add dims=1 to the options string and pThumb will output src, width and height all together. Like this: <img [[*imagetv:pthumb=`w=200&dims=1`]] alt="test image"> becomes <img src="/image-cache/test.d39f9375.jpg" width="200" height="300" alt="test image">.

Troubleshooting

If pThumb runs into a problem during thumbnail creation, it will simply return the input file name and exit. Usually this happens because some part of the input path or file name is incorrect and pThumb can’t find the image. A broken image link on the front end is a sure sign of this, meaning your web browser can’t find the image either. pThumb will actually correct for several common configuration mistakes and find the image anyway, but in some cases it can’t. Check the MODX error log for more insight into what’s going awry.

Changes from phpThumbOf 1.4.0

pThumb addresses the following open phpThumbOf issues:

  • [#37] Add a phpthumbof.jpeg_quality global default JPEG quality setting
  • [#46] add phpthumbof.check_mod_time option to refresh the cached image if the original has been modified
  • [#44] [#49] Prevent generation of identical images when the same image is used in multiple resources
  • [#48] [#49] Fix duplication of images with identical names in different directories
  • [#47] Exit quickly and silently when called with no filename, such as in the case of an empty placeholder
  • [#52] Make input filename handling more robust, particularly when MODX is installed in a subdirectory
  • [#53] Trim extension properly
  • [#54] [#50] Fix cache cleaning

In addition to that it:

  • Improves performance, especially on sites and pages which use phpThumbOf extensively. In some cases the difference can be very significant.
  • Adds better debugging output, like the page's resource ID to make finding broken images easy, or simple access to phpThumb's debug messages.
  • Improves phpThumbOfCacheManager behavior so that the cache isn't wiped out by default. The cache manager provides three different levels of cleaning and does better reporting on the number of files and the size of a cache.

pthumb's People

Contributors

exside avatar insytes avatar jpdevries avatar ncrossland avatar oo12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pthumb's Issues

Protocol Detection

Hello,

It looks like pThumb is unable to handle resources being called sans protocol (http://www.paulirish.com/2010/the-protocol-relative-url/) which is a valid method of serving files.

In these cases it should try connecting via https and then http in my opinion, avoiding a nonsecure warning if forcing http on a page being accessed securely.

The error if it helps:

[2013-08-22 23:30:48] (ERROR @ /index.php) [pThumb] Resource: 170 || Image: (none)
Retrieving //domain.com/images/file.jpg
Target filename: /home/domain/public_html/assets/components/phpthumbof/cache/domain.com/images/file.jpg
cURL error: <url> malformed  *** Skipping ***

Issue upgrading to modx 2.7.3

I'm not at work right now, so I'll get more info in the morning.

but gist is, whenever a resource is loaded that has a :pthumb= in the template, the resource will 500.
There was nothing in the error log that showed any issues.

Like I said, more info in the morning...

Thumbnails rights problem

When I set the system setting "new_file_permissions" to "644" pThumbs creates thumbnails that have rights "-w----r--" or octal "204" - so they can not be accessed.

Cache URL

Don't know if I'm missing somthing but I'd like to be able to control the url of the cache folder. You could do this in phpthumbof using the setting 'phpthumbof.cache_url'. Using pthumb I can only see the 'phpthumbof.cache_path' setting.

I have multiple sub domains, setup using contexts. The images are stored in one of the contexts and I'd like to be able to use them, via pthumb, across all the contexts using the absolute url.

Is this possible with pthumb or is there a better way of doing it?

pthumb prepends context base_url to cached path

I have a multilanguage website with different contexts in subfolders (base_path setting like /en/).

Now I try to get a thumb like this [[+myImageTv:phpthumbof=&w=100]] where [[+myImageTV]] outputs an absolute url like /assets/images/kunden.jpg which is correct and working.

But the thumb url from pthumb has the contexts base_url prepended like /de/assets/thumbscache/kunden.f44cb24e.jpg. Why is that happening?

pthumb.use_ptcache is enabled
pthumb.ptcache_images_basedir is assets/images
pthumb.ptcache_location is assets/thumbscache

Zoom Crop does not work

Hi, can not get zc to work

If I use phpthumb with small vertical image, it's zoomed, but not cropped. If i use resizer, it has richt aspect ratio, bat smallar as it should be...

pthumb should not try to scale/process svg images.

If a user enters an SVG image in a TV or a ContentBlocks field that is processing (resizing) the output image, pthumb throws a lot of errors in the log. Instead it should simply not process the SVG at all and just output the original svg-file. Most processing makes no sense for SVG or simply would not work.

Image size check

Sorry - wrong project and I can't figure out how to delete this. Please nuke it.

.pl in a filename causes pThumb to output nothing

Please see this line straight from the Error Log:
[2013-11-08 14:15:16] (ERROR @ /index.php) [pThumb] Resource: 598 || Image: /home/USER/public_html/assets/images/thumbnails/domain.pl.jpg

Kindly advise.

Not working good with other contexts

When I use pthumb in combination with other context (languages) then the thumbs are not created. You can see by example what I mean.

Correct: http://www.quilombo.eu/home/nieuws/2013/11/11/spekkenfestival2013/

Not correct (french site): http://www.quilombo.eu/fr/home/nieuws/2013/11/11/spekkenfestival2013/

I have followed the instructions of Babel to setup the different contexts and did this before on past websites (with succes). This is however the first website I use pthumb.

Can somebody please help me, it's urgent.

weird image dimension issue

Re pthumb
Hi,
I have a jpeg image (1920*956) that if I upload it using a Migx TV it causes the frontend template to render blank. If I upload any other image with that exact dimension it uploads fine and renders fine on the template. Why would some images cause phpthumbof or pthumb to malfunction. Do some jpegs carry extra data or something. Weirdest thing ever.
Thanks

Relative path problem when using phpThumb

When using phpThumb, if you give pThumb a relative path and your $_SERVER['DOCUMENT_ROOT'] is different than MODX_BASE_PATH, the file won't be found. Resizer works ok.

image height no longer reliably what I requested

I had been using pThumb 2.0.0-pl with no visible problems -- different-sized images that fit within a 1024 box were being resized to 240 w X 360 h every time I passed them to the output modifier:

[[+image:phpThumbOf=`w=240&h=360`]]

I would always get white borders as needed. But since I've upgraded to 2.1.0-pl2 from 2.0.0-pl, I now see the occasion failure, where the image is always 240 wide as expected, but the height is sometimes relative to the original width, instead of sized to the proper height with white borders added as needed. The original phpThumbOf also handled w=240&h=360 correctly every time before I upgraded to your replacement.

image

I've cleared the cache repeatedly and there are no log messages. This is MODX 2.2.10-pl. I use imageSlim (latest available) elsewhere but not on this content.

Thanks very much if you can take a look at this apparent regression!

Regards, watou

Prevent Resizer if unsupported filter option is given

Resizer only supports fltr[]=usm, fltr[]=wmt, and fltr[]=wmi. It would be nice to have a check that looks to see if any of the other filters are being used and override the Resizer option.

Other Filter Options:

  • stc
  • blur
  • gblr
  • sblr
  • bord
  • crop
  • ric
  • sat
  • ds
  • clr
  • gray
  • sep
  • mask
  • drop
  • elip
  • flip
  • bvl
  • fram
  • neg
  • th
  • rcd
  • hist
  • lvl
  • wb
  • edge
  • emb
  • mean
  • smth
  • gam
  • brit
  • cont
  • over

Filter errors with latest version

I have just upgraded to the latest verision (2.2.1) and there are problems with filters. The image gets generated in the correct cache folder and displays on the website all fine. However the filters (&fltr) I use are not being implemented.

My code:
[[+tv.image:pthumb=w=75&h=105&far=0&dpi=72&q=95&fltr=usm|60|0.8|3]]

Error:
(ERROR @ /foo/core/model/phpthumb/phpthumb.class.php : 1498) PHP warning: Invalid argument supplied for foreach()

Version 2.1.0-pl2 works fine. The filters are implemented and there are no errors in the Log.

pThumb on different contexts

Hi,

I have my main website running on the 'web' context and a blog running on a 'blog' context.
pThumb created images show perfectly on the 'web' context but will not show on the 'blog' context pages.

The error log is as follows:
[2018-03-18 18:11:27] (ERROR @ /home/stream7/public_html/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 156 || Image: (none) [pThumb remote images] Failed to cache http://stream7.co.uk/assets/images/blog/2017.jpg

I'm guessing I need to add some Context settings to the 'blog' but I cannot find which settings to add.

Thanks,

Can't create webp images with Resizer

I'm trying to create webp images with pthumb, but using Resizer instead of phpThumb seems to cause problems.

Steps to reproduce:

Create a webP Thumbnail with pThumb:

        <source 
            srcset="[[+crops.xl.url:pthumb=`w=1140&q=100&f=webP`]]"
            media="(min-width: 1200px)"
            data-breakpoint="xl"
            data-org="[[+crops.xl.url]]"
        />
  • Set phpthumbof.use_resizer == 0: webp images are created.
  • Set phpthumbof.use_resizer == 1: pthumb returns a crop in the original format located inside the image-cache and I find an error message inside the modx log file.
[2020-07-03 10:42:19] (ERROR @ /paas/*****/www/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 1 || Image: /paas/c0583/www/crops/lg.95a9428b.cm6p6087_1.jpg
Could not cache thumbnail to file at: /paas/*****/www/assets/image-cache/lg.95a9428b.cm6p6087_1.54dea866.webP
Resizer debug output:
    [0] => Resizer v1.0.1
    [1] => Using Imagick
    [2] => Input file: /paas/****/www/crops/lg.95a9428b.cm6p6087_1.jpg
    [3] => Input options: 
  'q' => '100',
  'f' => 'webP'
    [4] => *** Error *** Save operation failed

Environment:

  • modxcloud
  • modx 2.7.3
  • pthumb 2.3.3
  • contentblocks 1.8.15
  • resizer 1.0.2-beta

Regards,

pepebe

Abstract media sources into controllers

We have plenty of media sources now (other than Amazon S3), google cloud, dropbox, etc.

It would be great if we can use the controller by media source, rather than bolt the media source in the main class.

I'd be glad to help you on google cloud integration, but we need to refactor the phpThumbOf class.

What do you think?

Image path not working correctly on new version of pthumb

We're building a modx site in a subdirectory using pthumb and in the past it worked just fine. We just upgraded to the newest version (2.2.2-pl) and it broke the image path on the page. We backed pthumb back to an older version (2.1.0) and the problem no longer occurred.

The problem is with relative paths.

So, usually the cache generated image path should be like this:

http://site-ip-address/sub-directory-name/assets/components/phpthumbof/cache/blog-image.1cb372c3723d3bff2c4ba57824eb4507.jpg

where the modx base directory is there /sub-directory-name/

what happens on the latest version is that, the path generated is this:

http://site-ip-address/assets/components/phpthumbof/cache/blog-image.1cb372c3723d3bff2c4ba57824eb4507.jpg

it went outside the modx base directory /sub-directory-name/ .. as you can see, /sub-directory-name/ is not on the path anymore so the images don't load.

I'm not sure if it makes a difference or not, but we are using the old phpthumb call:

[[+tv.product_image:phpthumbof=w=220&h=160&zc=1]]

Snippet-Call doesn't work, but Output-Modifier works

Hi pThumb-Team,

I was having a weird issue with pThumb. Using this call:

[[!pthumb? &input=`[[+url]]` &options=`w=300&h=200&zc=C`]]

the image got only resized in width, but not in the height.
But using the Output-Modifier works as expected:

[[+url:phpthumbof=`
        &w=320
        &h=200
        &zc=C
`]]

I never had this issue before and the Snippet-Call-Version always worked, until today.

Maybe relevant: I used it in a ContentBlocks-Field. But actually it shouldn't be relevant, because the same behavior occurred in a simple content.

My Environment-Specifications:

  • MODX Revolution 2.4.3-pl
  • pThumb 2.3.3-pl
  • resizer 1.0.1-pl
  • PHP Version 5.6.19-nmm1
  • imagick module version 3.1.2
  • GD Version bundled (2.1.0 compatible)

I tried with and without using resizer. I also tried the different Preferred Graphics Library - Settings.
And what bugs me: Nothing in the error-logs.

Can someone reproduce this issue?

pThumb cannot handle Chinese characters in filenames

pThumb strips Chinese characters out of filenames.

Original file: 中環_復活節_c.jpg
Output file: __c.34a42792.jpg

Correct output should be: 中環_復活節_c.34a42792.jpg

This is a major problem. Perhaps it even extends to any unicode.

Issue with pThumb and Amazon S3 media source

I'm trying to;

Get pThumb to compress images from Amazon S3, and save the cached/compressed version back to S3 too.

I'm using the "aws-s3-media-source" package in the MODX repository https://github.com/modxcms/aws-s3-media-source. When I try and use the media source ID in the phpthumbof settings under "S3 Output Media Source", pThumb throws an error;

[2018-06-03 21:17:22] (ERROR @ /home/user/public/project/core/components/phpthumbof/model/phpthumbof.class.php : 89) [pThumb] No such S3 output media source: 5

Is this a bug or have I missed something here - apologies if I have!

Subdomain - Cache and Remote Cache Issues

PROBLEM 1 - I am trying to impliment pThumb using a image subdomain and am having issues with the cache path.

My subdomain Setup:
I have all images stored in a folder: /home/foo/public_html/img
This folder is accessed via a subdomain: http://img.foo.co.uk
I have setup a mediasource for this folder and have applied to the relevant image tv's.
I am accessing these images from these domains:
http://www.foo.co.uk
http://cn.foo.co.uk
http://ru.foo.co.uk
The above all works correctly.

pThumb Setup:
I apply pThumb to the tpl's: [[+tv.team-member-photo:pthumb=&w=100&h=100]]
Settings:
phpthumbof.cache_url: http://img.foo.co.uk/
pthumb.ptcache_images_basedir: img
pthumb.ptcache_location: img/cache
phpthumbof.use_resizer: Yes

The image url should display as:
http://img.foo.co.uk/cache/web/staff-photos/someone.2e0d42c8.jpg

Instead it displays as:
http://img.foo.co.uk/img/cache/web/staff-photos/someone.2e0d42c8.jpg

This results with broken links. The only way I can fix is by adding a .htaccess file to the '/home/foo/public_html/img' folder that rewrites as following:
RewriteEngine On
RewriteBase /
RewriteRule ^img/cache/(.*)$ cache/$1 [L,NE,R=301]

The image url still shows as:
http://img.foo.co.uk/img/cache/web/staff-photos/someone.2e0d42c8.jpg
but the images now display. This works accross all my domains (http://www.foo.co.uk, http://cn.foo.co.uk, http://ru.foo.co.uk)

How can I do this so don't need the .htaccess rewrite?

PROBLEM 2 - Also, pThumb is creating images in a remote cache folder:
/home/foo/public_html/assets/components/phpthumbof/cache/remote-images/img.foo.co.uk/

This shouldn't be the case, how do I stop this?

Thanks

whong image path

I have this call

in settings I have Images Base Directory set to assets/images/products/

I get this message in error log

[2014-06-24 12:49:17](ERROR @ /index.php) [pThumb] Resource: 2 || Image: (none)
File not found: /home/artisant/public_html/batic/artisan_wine_batic_rose.jpg *** Skipping ***

phpThumbOf or pThumb for PDF thumbnails

I'm using phpThumbOf on my site to generate resized images on my modx site. Now I tried to do a download area where I want to show some thumbnails of PDFs, but its not generating them. When I try to use pThumb, it returns the sourcefile path.

I already confirmed, that ImageMagick and php-imagick are installed and enabled.

Also my local development environment should allow to use exec so I can't see why this isn't working.

Did someone got this to work already?

[Feature] - Ability to "mark" a remote domain as "local"

One might want to define a (sub)domain for assets, which could be hosted locally.

To do so, we define a media source with an absolute URL (ie. //assets.domain.tld).

phpThumb will consider this as a remote URL, doing an extra request via cURL.

It could be handy to be allowed "map" some domains to a folder, ie. assets.domain.tld to /var/www/assets/

Hope it makes sense.

Error cleaning cache

I can't clear my cache anymore. I get a clean console with just this text: "Console running..."

My apache error log states:
[Tue Nov 12 19:08:45 2013] [error] [client xx.xx.xx.xx] PHP Parse error: syntax error, unexpected ':' in /core/components/phpthumbof/model/pthumbcachecleaner.class.php on line 100, referer: http://www.xxx.tld/manager/?

// fixed it, will hand in pull request

Cannot install via Package Management

Using MODX 2.2.14-pl i am not able to install this extra via package management. When i click the install button, the "console running ..." message appears but nothing further. If i close this window the extra seems to be installed but it isn't. If i click remove the console claims that no files where found for removing.

Error on 2.3 Upgrade

I get the following when when upgrading a site to Modx 2.3 that utilizes pThumb and it kills the page.
Fatal error: Cannot redeclare phpthumb::__destruct() in /home/ties/public_html/core/model/phpthumb/phpthumb.class.php on line 254

Progressive JPEG Support

I ran into a small aesthetic issue, I was wondering if it was possible to add support for progressive jpeg output.

I'm using a lazyloading image pattern that uses a super condensed version of the image with a blur effect on it, and then loads into the actual image.
Using pthumb has been working great for that, except that all of my progressive jpegs get turned into regular jpegs. The loading effect of the whole image loading like a printed ruins the whole effect.

Doing a small amount of research it looks like Imagine found a way to implement this here, I'm not well versed in PHP, so I wasn't really able to understand what exactly was going on in there.

Is this something that is possible to add?

Output dataURIs instead of paths

It would be nice if there was an option like &datauri=1 which would output a base64 encoded data source of the generated thumbnail instead of the direct path (to reduce requests) with a check included for old IEs (IE5-8) that do not support dataURIs fully (IE8 up to 32kb, but not more...) and if detected the normal path should be returned. If there is motivation around to also support IE8, there could be a check of the thumbnails filesize and if it's smaller than 32kb it can be encoded for IE8 too.

This can be a stupid preg_match check for user agent, I think this should be enough, even if not completely reliable:

// 3-8 because if we take 1-8 it also catches IE10/11, could also be 5-8
preg_match('#(?i)msie [3-8]#', strtolower($_SERVER['HTTP_USER_AGENT']));

Maybe a second property like datauriMaxSize=32768 (in bytes) could also be included to not have all pictures encoded (as particularely big ones are a huge bloat to the html).

The generated dataURI strings should also be cached as it can generate quite some load if done with each request.

If I find some time I'll fiddle around with the possibilities, so this issue is not just a "request" but also a reminder for myself =)

thanks for your great work with this extra!

Images being cached twice

We are using pThumb to grab remote images and create thumbnails. We use S3 to store the thumbnails and this works fine, but images are also being stored in assets/components/phpthumbof/cache.

Is this a bug or something I've done wrong?

Duplicate path when using phpThumb on Windows

pThumb doesn't account for Windows' drive letter mappings and incorrectly prepends the first part of the path to itself, sending paths like this to phpThumb: C:/inetpub/vhosts/framework-test.local/public/C:/inetpub/vhosts/framework-test.local/public/...

useResizer=0 and still won't perform gray filter

When using pThumb 2.0.0-pl, I could successfully use the gray image filter. Now with 2.1.0-pl2, even if I explicitly set phpthumbof.use_resizer to No in the MODX System Settings, or pass &userResizer=0 in the options, I still have the other options work but the fltr[]=gray is not performed.

[[+logo:phpthumbof=`&h=40&f=png&fltr[]=gray&useResizer=0`]]

Problems with webp Support

Overview:

Support of webp output seems to be broken:

  • Resizer doesn't work at all (see: #64)
  • Webp thumbs are much bigger then the original jpg.
  • Also the webp format seems to be fake and the images is still a jpg on the inside.

Example: Webp / Jpeg Thumbs created by pthumb (same source image):

  • The webp image blows up from 72 to 202kB.
  • Even though both images have differnt extensions (jpg, webP), both have the same file type (JPEG-Bild = jpeg image)

image

This is how a "real" webp image properties look like in gimp:

image

I am aware that the image shows the format as webP. Changing it to webp doesn't change the result.

I have found a forum thread that support my findings:
https://community.modx.com/t/pthumbtransparent-webp-images/1999/18

Environment:

  • modxcloud
  • modx 2.7.3
  • pthumb 2.3.3
  • contentblocks 1.8.15
  • resizer 1.0.2-beta

Scaling up/down to exact size

I'm trying to scale images both up/down to meet specific dimensions. I thought zoom crop did this. For example an image that is 140x245 that should be scaled up to 325x445

<img src="[[pthumb? &input=`/shared/images/offers/[[+thumbnail]]` &options=`&w=325&h=445&aoe=1&q=100`]]" />

Results in 254x445

<img src="[[pthumb? &input=`/shared/images/offers/[[+thumbnail]]` &options=`&w=325&h=445&zc=1&q=100`]]" />

Results in 129x313

<img src="[[pthumb? &input=`/shared/images/offers/[[+thumbnail]]` &options=`&w=325&h=445&iar=1&q=100`]]" />

Results in 325x445 but undesirable as not proportionate.

<img src="[[pthumb? &input=`/shared/images/offers/[[+thumbnail]]` &options=`&w=325&h=445&far=1&q=100`]]" />

Results in 254x445.

Am I missing something? I've tried a mixture of combinations involving aoe, far, iar and zc but no improvements.

Adding background color to transparent png and output format jpg

Can you confirm that it's really not possible to add a background color to a transparent png and change the output format to jpg?

On the phpthumb demo page it works... http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php#x9

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000`]]

Result: red background, png. Close, but still a (large) png.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000&f=jpg`]]

Result: black background, jpg.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000` &useResizer=`0`]]

Result: cropped image (squared, ???), white background, png.

[[phpthumbof? &input=`transparent.png` &options=`bg=FF0000&f=jpg` &useResizer=`0`]]

Result: cropped image (squared, ???), white background, jpg.

Webp Support

The ability to export webp image format, lossy or lossless by choice, with alpha for transparency supported. With google speed rankings now taking this into account, it would be extremely useful.

ImageMagick for MODX

Hi oo12,
this is more a "meta" or "mega" issue: :-D
Do you see a way of integrating ImageMagick into MODX? Something like "passing the parameters over to IM and store the returning image in the MODX cache" – or an MODX-IM cache like pThumb does it.
I came up with this idea because I wanted to use blend modes which are not available in PhpThumb. IM can do it (http://www.imagemagick.org/Usage/compose/) and a lot more cool stuff.
Also IM knows how to handle CMYK-PDFs, which, you remember, is something where Resizer struggles with.
I would be happy if we could talk/chat about this. Interested?

cheers
Oliver
MODX AMB Cologne, DE

problem with auto rotate along with other arguments when using Resizer

WHile trying to use the auto rotate attribute, I have success when doing like this:

[[+image:pthumb=`&ar=x`]]

As soon as I add other arguments, it stops rotating:

[[+image:pthumb=`&ar=x&w=160&h=120&zc=1`]]

Couldn't find any reference on the auto rotation elements that does not allow argument nesting:

  ar = Auto Rotate: set to "x" to use EXIF orientation
       stored by camera. Can also be set to "l" or "L"
       for landscape, or "p" or "P" for portrait. "l"
       and "P" rotate the image clockwise, "L" and "p"
       rotate the image counter-clockwise.

I am using Resizer.
Any known limitation with Resizer? All works fine when not using Resizer.

Thanks in advance

Caching outside of MODX

When trying to harden a MODX installation, I like to put "manager", "core" etc. on one (sub)domain and the website(s) on another. Like this:

/htdocs
   /modxadmin.mysites.tld      << MODX CMS lives here
   /myothersites.tld
      /www                     << This is one of many sites driven by one MODX
      /subdomainZ              << This is one of many sites driven by one MODX
   /another-domain.tld         << This is one of many sites driven by one MODX
   /some-website.tld           << This is one of many sites driven by one MODX

This way I can easily update MODX (everything stays together) and every website/subdomain is stored separately in its own folder: index.php, /assets, config.inc.php, .htaccess. Done.

But pThumb does not like this layout: "pThumb Cache Location: The directory to store cached images. The path is relative to the MODX base directory, which is generally your web root."

This leads to the problem, that the thumbs are generated and stored in the MODX root dir and cannot be accessed from the "outside".
The only way (i found) to solve this is by using symbolic links (on Linux) and build a tunnel through the filesystem to reach a cache folder. This works but is somehow not elegant ;-) – and not maintainable via MODX itself.

Is there a way of telling pThumb that the cache is "outside" the modx-root – just somewhere on the server?
If pthumb.ptcache_location would be an absolute path life would be even better. Maybe there could be a "relative/absolute" switch like the is with Media Sources. Then everybody could decide where the cache is stored – and the setting could be altered for every context.

What do you think of the idea of absolute cache-paths?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.