Code Monkey home page Code Monkey logo

nystudio107 / craft-imageoptimize Goto Github PK

View Code? Open in Web Editor NEW
235.0 10.0 37.0 29.69 MB

Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.

Home Page: https://nystudio107.com/plugins/imageoptimize

License: Other

PHP 72.51% JavaScript 3.45% CSS 0.89% Vue 6.53% Twig 15.66% Dockerfile 0.03% Makefile 0.38% TypeScript 0.54%
craftcms craft-plugin craft3 image optimzation image-variants optimize-images imgix

craft-imageoptimize's Introduction

Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status

ImageOptimize plugin for Craft CMS 5.x

Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like imgix or Thumbor, with zero template changes.

Screenshot

Note: The license fee for this plugin is $59.00 via the Craft Plugin Store.

Requirements

This plugin requires Craft CMS 5.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require nystudio107/craft-imageoptimize
    
  3. Install the plugin via ./craft install/plugin image-optimize via the CLI, or in the Control Panel, go to Settings → Plugins and click the “Install” button for Image Optimize.

You can also install ImageOptimize via the Plugin Store in the Craft Control Panel.

Documentation

Click here -> Image Optimize Documentation

ImageOptimize Roadmap

Some things to do, and ideas for potential features:

  • Consider supporting image optimization services like Cloudinary, TinyPNG, kraken.io, Uploadcare, and ImageOptim
  • Add support for additional image optimization tools

Brought to you by nystudio107

craft-imageoptimize's People

Contributors

dennisfrank avatar engram-design avatar friartuck6000 avatar ilicmarko avatar jakedohm avatar jamesmacwhite avatar joshangell avatar khalwat avatar makeilalundy avatar markhuot avatar mildlygeeky avatar missmatsuko avatar qrazi avatar seibert-io avatar smockensturm avatar svale avatar timkelty 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

craft-imageoptimize's Issues

Unable to upload jpg when Create Placeholder Silhouettes is enabled

Description

Getting the following error message when attempting to upload a jpg (sized 2000 × 1239) to an asset volume with an attached OptimizedImages field:

Upload failed. The error message was: “Call to undefined function nystudio107\imageoptimize\lib\imagecreatefromjpeg()”

Looks like there's a imagecreatefromjpeg call in ./vendor/nystudio107/craft-imageoptimize/src/lib/Potracio.php. Setting createPlaceholderSilhouettes => false suppresses the upload error.

Additional Info

The attached OptimizedImages field has only one image variant. It's configured like:

Field Setting Value
Width 1440
Enforce Aspect Ratio false
Retina Sizes none
Quality Very High
Image Format Auto

Composer dependencies look okay:
composer install returns "Nothing to install or update"
composer status returns "No local changes"

ImageOptimize is using Craft native transforms with the following libs successfully installed:

Optimization Libs
jpegoptim
optipng
svgo
gifsicle
cwepb
Software Version
ImageOptimize 1.4.13
Craft Craft Pro 3.0.0-RC9
PHP 7.0.22
Image driver Imagick 3.4.0RC6 (ImageMagick 6.8.9-9)
Linux distribution Ubuntu 16.04.2 LTS

Transform images like Crafts ”Stretch” mode instead of cropping

It would be great if one could have the option of not crop the image, and only stretch it proportionally after a desired width or height, like Crafts native ”Stretch” mode. If I understood how this plugin is working, one will need to set up an Asset Source each per image format, quite often we use mixed images of 4:3, 1:1, 16:9,9:16 etc which will make us end up with a lot of Asset Sources.

Add support for Imgix secure URLs

Imgix gives us the ability to enable "secure URLs" on a source which requires image URLs to be signed with a secret token to be valid. Right now, image URLs generated with ImageOptimize are not signed so they're not valid when secure URLs are enabled, which makes ImageOptimize less secure! Haha no but it would be great if you could support it. ;)

More info: https://docs.imgix.com/setup/securing-images

Moving images to a folder makes the site unresponsive

When ImageOptimize is enabled and you try to move some images to a subfolder, it optimizes all the images again, which it shouldn't do as the images themselves have not been changed.

When you try to move a lot of them at once, everything just hangs and makes the site unresponsive.

Placeholders adhering to the different variations

This is probably more of a feature request than a bug.

Basically, I am attempting to use this plugin to output an image in two variations; a 16:10 variation and a 1:1 variation.

In addition to just displaying the image, I want to lazy-load it while using a placeholder (doesn't matter which one, but let's say the LQIP-version) until the actual image is loaded.

Now, on large screens, displaying the 16:10 variation, the placeholder works nicely as it is the same size as the actual image. However, on smaller screens (displaying the 1:1 variation) the placeholder is still of a 16:10 aspect, making it smaller than the actual image.

So - would it be possible to get an extension to the various placeholder-methods so that we can somehow access the placeholders for each individual variation?

Then we could do something akin to src="{{ placeholderImage }}" data-srcset="{{ srcset }}" data-placeholder-srcset="{{ placeholders }}" on the img-element and implement custom JS-logic that set's the correct src based on viewport-width or something (read: I am totally open to completely different methods of implementing this if you can think of a better way)

Quicker edit access

If it's possible, adding a click event to the "Focal Point set" text, or adding an "Edit Image with Craft" button that would open up Craft's image editor would be a nice convenience for clients.

I realize this only saves about 2 clicks, but if you're quickly processing a bunch of images, it would be a bit of a time saver.

[error][Error] Error: Call to undefined function nystudio107\imageoptimize\lib\imagecreatefromjpeg() in /var/www/vendor/nystudio107/craft-imageoptimize/src/lib/Potracio.php:194

2018-02-09 23:12:05 [172.22.0.1][1][-][info][nystudio107\imageoptimize\services\OptimizedImages::addVariantImageToModel] URL created: /images/articles/_1200x743_crop_center-center_82_line/phil-botha-424950.jpg
2018-02-09 23:12:06 [172.22.0.1][1][-][error][craft\queue\QueueLogBehavior::afterError]  [244] Resaving Assets in Cikk képek (attempt: 1) - Error (time: 0.320s): Call to undefined function nystudio107\imageoptimize\lib\imagecreatefromjpeg()
2018-02-09 23:12:06 [172.22.0.1][1][-][error][Error] Error: Call to undefined function nystudio107\imageoptimize\lib\imagecreatefromjpeg() in /var/www/vendor/nystudio107/craft-imageoptimize/src/lib/Potracio.php:194
Stack trace:
#0 /var/www/vendor/nystudio107/craft-imageoptimize/src/services/Placeholder.php(130): nystudio107\imageoptimize\lib\Potracio->loadImageFromFile('/var/www/storag...')
#1 /var/www/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(171): nystudio107\imageoptimize\services\Placeholder->generatePlaceholderSvg('/var/www/storag...')
#2 /var/www/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(249): nystudio107\imageoptimize\services\OptimizedImages->generatePlaceholders(Object(craft\elements\Asset), Object(nystudio107\imageoptimize\models\OptimizedImage), 1.6137472283814)
#3 /var/www/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(101): nystudio107\imageoptimize\services\OptimizedImages->addVariantImageToModel(Object(craft\elements\Asset), Object(nystudio107\imageoptimize\models\OptimizedImage), Object(craft\models\AssetTransform), Array, 1.6137472283814)
#4 /var/www/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(274): nystudio107\imageoptimize\services\OptimizedImages->populateOptimizedImageModel(Object(craft\elements\Asset), Array, Object(nystudio107\imageoptimize\models\OptimizedImage))
#5 /var/www/vendor/nystudio107/craft-imageoptimize/src/jobs/ResaveOptimizedImages.php(77): nystudio107\imageoptimize\services\OptimizedImages->updateOptimizedImageFieldData(Object(nystudio107\imageoptimize\fields\OptimizedImages), Object(craft\elements\Asset))
#6 /var/www/vendor/yiisoft/yii2-queue/src/Queue.php(213): nystudio107\imageoptimize\jobs\ResaveOptimizedImages->execute(Object(craft\queue\Queue))
#7 /var/www/vendor/yiisoft/yii2-queue/src/cli/Queue.php(139): yii\queue\Queue->handleMessage('244', 'O:52:"nystudio1...', '300', 1)
#8 /var/www/vendor/craftcms/cms/src/queue/Queue.php(95): yii\queue\cli\Queue->handleMessage('244', 'O:52:"nystudio1...', '300', 1)
#9 /var/www/vendor/craftcms/cms/src/controllers/QueueController.php(84): craft\queue\Queue->run()
#10 /var/www/vendor/craftcms/cms/src/controllers/QueueController.php(104): craft\controllers\QueueController->actionRun()
#11 [internal function]: craft\controllers\QueueController->actionRetry()
#12 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /var/www/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /var/www/vendor/craftcms/cms/src/web/Controller.php(80): yii\base\Controller->runAction('retry', Array)
#15 /var/www/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('retry', Array)
#16 /var/www/vendor/craftcms/cms/src/web/Application.php(241): yii\base\Module->runAction('queue/retry', Array)
#17 /var/www/vendor/craftcms/cms/src/web/Application.php(451): craft\web\Application->runAction('queue/retry', Array)
#18 /var/www/vendor/craftcms/cms/src/web/Application.php(212): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#19 /var/www/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#20 /var/www/html/index.php(21): yii\base\Application->run()
#21 {main}
2018-02-09 23:12:06 [172.22.0.1][1][-][info][yii\db\Command::execute] UPDATE `queue` SET `fail`=1, `dateFailed`='2018-02-09 22:12:06', `error`='Call to undefined function nystudio107\\imageoptimize\\lib\\imagecreatefromjpeg()' WHERE `id`='244'
2018-02-09 23:12:06 [172.22.0.1][1][-][profile begin][yii\db\Command::execute] UPDATE `queue` SET `fail`=1, `dateFailed`='2018-02-09 22:12:06', `error`='Call to undefined function nystudio107\\imageoptimize\\lib\\imagecreatefromjpeg()' WHERE `id`='244'
2018-02-09 23:12:06 [172.22.0.1][1][-][profile end][yii\db\Command::execute] UPDATE `queue` SET `fail`=1, `dateFailed`='2018-02-09 22:12:06', `error`='Call to undefined function nystudio107\\imageoptimize\\lib\\imagecreatefromjpeg()' WHERE `id`='244'
2018-02-09 23:12:06 [172.22.0.1][1][-][info][yii\db\Command::execute] UPDATE `queue` SET `dateReserved`=NULL, `timeUpdated`=NULL, `progress`=0 WHERE `timeUpdated` < 1518214326 - `ttr`
2018-02-09 23:12:06 [172.22.0.1][1][-][profile begin][yii\db\Command::execute] UPDATE `queue` SET `dateReserved`=NULL, `timeUpdated`=NULL, `progress`=0 WHERE `timeUpdated` < 1518214326 - `ttr`
2018-02-09 23:12:06 [172.22.0.1][1][-][profile end][yii\db\Command::execute] UPDATE `queue` SET `dateReserved`=NULL, `timeUpdated`=NULL, `progress`=0 WHERE `timeUpdated` < 1518214326 - `ttr`
2018-02-09 23:12:06 [172.22.0.1][1][-][info][yii\db\Command::query] SELECT *
FROM `queue`
WHERE ((`fail`=FALSE) AND (`timeUpdated` IS NULL)) AND (`timePushed` <= 1518214326 - `delay`)
ORDER BY `priority`, `id`
LIMIT 1
2018-02-09 23:12:06 [172.22.0.1][1][-][profile begin][yii\db\Command::query] SELECT *
FROM `queue`
WHERE ((`fail`=FALSE) AND (`timeUpdated` IS NULL)) AND (`timePushed` <= 1518214326 - `delay`)
ORDER BY `priority`, `id`
LIMIT 1
2018-02-09 23:12:06 [172.22.0.1][1][-][profile end][yii\db\Command::query] SELECT *
FROM `queue`
WHERE ((`fail`=FALSE) AND (`timeUpdated` IS NULL)) AND (`timePushed` <= 1518214326 - `delay`)
ORDER BY `priority`, `id`
LIMIT 1

Control panel errors after update

Hi,

I just updated Craft 3 from RC9 to RC11 and also updated ImageOptimize to the latest version. Since the update I'm getting several errors on control panel templates.

Image Optimize settings:

Twig_Error_Runtime: Calling unknown method: nystudio107\imageoptimize\models\Settings::imgixSecurityToken() in /home/vagrant/Development/projects/grappa-bruno/vendor/nystudio107/craft-imageoptimize/src/templates/settings.twig:63

Image Optimize field:

Calling unknown method: nystudio107\imageoptimize\fields\OptimizedImages::displayOptimizedImageVariants()

I'm also getting an error when I try to access the context menu with the previews on an asset.

Any ideas? Thanks.

Default Aspect Ratios — Last one is missing

'defaultAspectRatios' => [
    ['x' => 16, 'y' => 10],
    ['x' => 16, 'y' => 9],
    ['x' => 4, 'y' => 3],
    ['x' => 1, 'y' => 1],
    ['x' => 10, 'y' => 16],
    ['x' => 3, 'y' => 4],
    ['x' => 3, 'y' => 4],
],< 

image

When I double the last line it works as expected.

3.0.0-beta.20 beaks the translation files

The plugin is broken with the last Craft update.

Please note one of the release note's of the update.

{note} Plugin handles are kebab-cased now rather than camelCased. Plugins’ Craft::t() and |t() calls, translation files, and template paths must be updated accordingly, as well as any plugin config files in Craft 3 projects.

Please let me know if i can assist you with the fix!

Image Quality issues.

When using imageoptimize i get huge problems with image quality. The example image is 2500px width and is beeing downscaled to 1200px by imageoptimize. (webp get's even worse)

Standard Image transforms of Craft3 are doing a good job from quality side.

What to consider to get the the best image quality? Configuration not changed from standard so far.

Detail in image (100%)
image

same detail in original image (100%):
image

fopen() failed to open stream on temp/ directory

Hey there. Awesome plugin. I'm looking to jump into some of the more robust features of this plugin but am running into some errors.

I'm fairly new to Craft 3 so I'm still getting accustomed to how Craft handles temporary assets and transforms.

I'm getting the following error when trying to save out assets:

fopen() failed

Likewise when I try to use the webp transform, I get the following error:

filesize() stat failed

Clearly it has to do with Craft not being able to read from my template directory. I've adjusted permissions to 777 to test, as well as chowning the folder to my root username to no avail.

Some more information on my setup: I'm using remote asset volumes through Rackspace Cloud Files. Before I attached an OptimizedFiles field to my Asset field I'm able to save out assets just fine. My assets are being saved to the /storage/runtime/temp/ directory, but I guess they're just not being read.

Not sure if this is an error with the plugin, or an error with my setup, but would love some guidance and an opportunity to contribute to the instructions to make sure no one else gets caught with this in their transition from Craft 2 -> Craft 3.

Transforms folders don't get removed on image deletion - webp remains

When ImageOptimize is enabled, .webp files get created for both ImageOptimize transforms (using the field type) and standard Craft transforms. When an image is deleted from Craft (through Assets), the .jpg transforms get deleted with the image, but .jpg.webp files remain together with the folders (eg. _600x337_crop_center-center_82_line).

It would be good to delete both file types + the folders or it will leave unused folders/files on the server.

Thanks! (great plugin!)

[FR] Request for watermark support

Coming in with a feature request per request from #craftcms on slack (I'm apparently the second person today that wants this functionality). Thanks!

Variant display skewed if variants have the same width

Hey @khalwat

Great plugin as ever! Just noticed that when previewing the variants on an asset, if all the variants have the same width it seems to only be using the last transform on all the previews.

This causes a bit of an issue with the previews looking skewed if the aspect ratios are different.

Have put together a short video that should show the issue: http://x.n43.me/3Y2O020C0M1T

Keep up the great work!

Clear Cache / Transforms

What's the right way to clear Image Caches.
Case is: The Client changes the Focal Point but no images are recreated.
I must delete them manually from /web/uploads/images/XXX

Imager have the Option to Select an Image within the Assets and Choose: "Clear Transforms"
Maybe that would be a solution for ImageOptimize

First parameter must either be an object or the name of an existing class

Hi.

Just installed the plugin on Craft3-RC10.1 and hooked it up to Imgix. In the backend, the image-variations show up just fine when editing an asset. However, in the frontend, I get the error listed in the subject.

My template-code is:

{% if section.images|length %}
  <div class="section__images">
    {% for image in section.images.all %}
      {% set optimizedImages = image.variations %}
    {% endfor %}
  </div>
{% endif %}

Obviously, I have tried with the various methods of displaying the images as per the examples - but as you can see the error occurs before I attempt to display them.

The error stems from /vendor/nystudio107/craft-imageoptimize/src/imagetransforms/ImgixImageTransform.php line 88, which reads if (property_exists($transform, 'interlace')) {

Let me know if you need any screenshots or details about my various settings etc :)

Can not add Variants when defaultVariants is empty

I don't need default Variants cause I create three fields (square, landscape, portrait). But when I remove the default I can't add Variants on backend side.

        // Default image variants
        'defaultVariants' => [
            /*[
                'width'          => 100,
                'useAspectRatio' => false,
                'aspectRatioX'   => 1.0,
                'aspectRatioY'   => 1.0,
                'retinaSizes'    => ['1'],
                'quality'        => 82,
                'format'         => 'jpg',
            ],*/
        ],

image

accessing Image Optimize plugin from another plugin

I'm trying to use the image optimizer with the element-api plugin in. I am writing an app for a big touch screen. So the images won't be changing sizes, but I won't have control of the images they put in the cp. After calling the image, I would like to modify it prior to converting it to json.
my questions are:

  1. how do I call your plugin? my closest guess is: use nystudio107\imageoptimize\ImageOptimize;
    this is incorrect.
  2. how do I call the createOptimizedImages() ?
public function includeLeft(Entry $entry)
  {
    return $this->collection($entry->left, function($model) {
      $image = $model->image;
      $optimzedImage = ImageOptimize::getInstance()->createOptimizedImages(
        $image,
        [
          [
            'width' => 200,
            'useAspectRatio' => true,
            'aspectRatioX' => 1.0,
            'aspectRatioY' => 1.0,
            'retinaSizes' => ['1'],
            'quality' => 82,
            'format' => 'jpg',
          ],
        ]
      );
        return $optimzedImage;
    }, 'left');
  }

Request for inline CSS support

It would be great to have an option to print the code in as inline CSS (complete with @media queries for all sizes/retina settings) for use as a background: url(imagefile.here); of a HTML element.

I'm thinking something along the lines of:

{% set optimizedImage = entry.myAsset.one().optimizedImageField %}
<div id="my-div" style="background-color: {{ optimizedImage.colorPalette().one() }}; {{ optimizedImage.srcsetCss() }}"></div>

Turns into (sloppy example but you get the idea):

{% set optimizedImage = entry.myAsset.one().optimizedImageField %}
<div id="my-div" style="background-color: #ff0000; background-image: url(/myAsset/mobileSize.jpg); @media only screen and (min-width: 768px) { background-image: url(/myAsset/tabletSize.jpg); }; @media only screen and (min-width: 980px) { background-image: url(/myAsset/desktopSmall.jpg); }; @media only screen and (min-width: 1280px) { background-image: url(/myAsset/desktopMed.jpg); }; @media only screen and (min-width: 1440px) { background-image: url(/myAsset/desktopLarge.jpg); };"></div>

Thoughts?

imgix api-key parameter added to all image requests

When using imgix, all image requests have the api-key appended as a url parameter. I'm assuming this should only happen for purge requests, and not for normal public requests?

e.g.

https://mydomain.imgix.net/filename.jpg?api-key=[key-from-plugin-config]&auto=compress%2Cformat&crop=focalpoint&domain=mydomain.imgix.net&fit=crop&fp-x=0.5&fp-y=0.5&h=450&ixlib=php-1.2.0&sharp=50&w=600

JPG variant does not exist,..

I added the field type, I updated the focal point, the placeholders are generated, color palette is generated.

But all the variants give the same message. XXX variant does not exist,..

Am I missing something? My config lives in config/image-optimize.php
I'm using Craft 3 rc5 and assets are in a symlinked shared folder.

screenshot 2018-01-11 17 12 05

screenshot 2018-01-11 17 14 09

'gd not installed' error

After one of the latest updates i get this error "Variable "gdInstalled" does not exist" though i have GD installed. And before this update plugin was working fine and placeholder silhouettes were created. Can you check this?

Cache dynamically created images

It would be nice if the plugin would cache images created dynamically in the template, as we usually have a lot of different aspect ratios for images used through-out the site. So it would be really hard to set up image variants for each image type. And it's also quite hard to swallow a 10s load time for a page that has 6 images.

"Smart" responsive images

Looking at the implementation of the spatie/laravel-medialibrary implementation of responsive images, I'm thinking/suggesting you could implement a few things that they do to make using it a lot easier.

One of the things they're doing is automatically calculating the necessary transform width for an image based on when it is 20% smaller. (https://github.com/spatie/laravel-medialibrary/blob/v7/src/ResponsiveImages/WidthCalculator/FileSizeOptimizedWidthCalculator.php) using this, you wouldn't need to specify all the image widths manually.

They also implemented a pretty smart way to use the placeholder without having to rely on something like lazysizes: https://github.com/spatie/laravel-medialibrary/blob/v7/resources/views/responsiveImageWithPlaceholder.blade.php

Of course this is in a Laravel environment so they probably have a bit more flexibility as to what they can do.

Minimum Stability issue

Getting the following error when installing on clean craft3.beta 12 setup

$ composer require nystudio107/craft3-ImageOptimize -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /private/etc/ssl/cert.pem: valid
Executing command (/Users/dan/Sites/hoban): git branch --no-color --no-abbrev -v
Executing command (/Users/dan/Sites/hoban): git describe --exact-match --tags
Executing command (/Users/dan/Sites/hoban): git log --pretty="%H" -n1 HEAD
Executing command (/Users/dan/Sites/hoban): hg branch
Executing command (/Users/dan/Sites/hoban): fossil branch list
Executing command (/Users/dan/Sites/hoban): fossil tag list
Executing command (/Users/dan/Sites/hoban): svn info --xml
Reading /Users/dan/.composer/composer.json
Loading config file /Users/dan/.composer/composer.json
Reading /Users/dan/Sites/hoban/vendor/composer/installed.json
Loading plugin yii\composer\Plugin
Loading plugin craft\composer\Plugin
Running 1.4.1 (2017-03-10 09:29:45) with PHP 7.0.17 on Darwin / 16.5.0
Downloading https://asset-packagist.org/packages.json
Writing /Users/dan/.composer/cache/repo/https---asset-packagist.org/packages.json into cache
Downloading https://packagist.org/packages.json
Writing /Users/dan/.composer/cache/repo/https---packagist.org/packages.json into cache
Reading /Users/dan/.composer/cache/repo/https---asset-packagist.org/p-provider-latest-.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2013.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2014.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2015.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2016.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2016-07.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2016-10.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2017-01.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-2017-04.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-archived.json from cache
Reading /Users/dan/.composer/cache/repo/https---packagist.org/p-provider-latest.json from cache


  [InvalidArgumentException]
  Could not find package nystudio107/craft3-ImageOptimize at any version for your minimum-stability (beta). Check the package spelling or your minimum-stability


Exception trace:
 () at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/src/Composer/Command/InitCommand.php:643
 Composer\Command\InitCommand->findBestVersionForPackage() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/src/Composer/Command/InitCommand.php:365
 Composer\Command\InitCommand->determineRequirements() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/src/Composer/Command/RequireCommand.php:117
 Composer\Command\RequireCommand->execute() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/vendor/symfony/console/Command/Command.php:267
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/vendor/symfony/console/Application.php:846
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/vendor/symfony/console/Application.php:191
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/src/Composer/Console/Application.php:227
 Composer\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/vendor/symfony/console/Application.php:122
 Symfony\Component\Console\Application->run() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/src/Composer/Console/Application.php:100
 Composer\Console\Application->run() at phar:///usr/local/Cellar/composer/1.4.1/libexec/composer.phar/bin/composer:54
 require() at /usr/local/Cellar/composer/1.4.1/libexec/composer.phar:24

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

Other NYStudio107 plugins installing, just not this one.

Have tried shifting minimum stability down to dev with the same error.

Queue image variants

Is it possible to queue all generation of image variants?

Uploading/saving an image now takes a long time for the user while they won't instantly need to view the variants anyway.

Add config to enable or disable optimizations

In most situations I don't need to optimize my transforms in my local environment, so I don't install and manage libraries like jpegoptim in my dev environment. I usually match my staging environment to my production, so if I need to test things like creating a webp variant or doing image compression, I would do it on staging.

It would be great to either have an overall kill switch config option to simply ignore all optimizations from third-party libraries, or to have kill switches to enable/disable each type of optimization.

I'd still like to see the image transforms happen in my dev environment, so ideally the option to enable/disable optimizations would just mean that the functions that return an optimized URL would simply return a URL of the transformed image.

NOTE: Right now I'm getting some errors that I think are based on the fact that I don't have the libraries installed, but this config option would not only fix these errors, but I think it would speed up local development by skipping extra steps of attempting the optimizations in the first place.

Deleted images should be purged from Imgix

When an image is deleted from Craft entirely (from assets), it should probably also call the "purge image" API call on Imgix / imgix docs link:

curl "https://api.imgix.com/v2/image/purger" \
  -u "$API_KEY:" \
  -d "url=$URL_TO_PURGE"

Not sure what to do about the cached transforms when an image is purged - Imgix says it changes cache headers, but I was getting the old image (after manually purging the image from Imgix dashboard) until I did a hard reset in Chrome ("Empty cache and hard reload").

All the variants can be deleted.

It is possible to remove all variants which then makes it not possible to re-add a variant once all the variants have been deleted.

In the dropdown to delete variants the last variant shows the delete grayed out but it still functions.

Reloading the field after saving it with no variants will repopulate it will all the default variants.

Missing field type

Installed version 1.3.2

Trying to add a ImageOptimize field. Can select it from the field type dropdown but after saving the field it responds with: "The field type “nystudio107\imageoptimize\fields\OptimizedImages” could not be found."

https://d.pr/free/i/ndVNxZ

Add option to resize and resave uploaded image and discard the original upload

If a client uploads an image that is too large (either due to format - eg. TIF - or to size - eg. huge 10k x 10k image), there should be an option to enforce:

  • maximum size (fit to bounds) in pixels - width and height
  • image format (probably good to keep png=png, jpg=jpg and just convert other image types to jpg)

Another benefit of this could be quality - there is an old trick (and a plugin) for Photoshop where if you're a professional photographer and really want to optimize your photos for the web (though this was in pre-retina times), you would run it through a few consecutive unsharp mask filters - so resize down a bit, unsharp mask slightly, resize down a bit, unsharp... etc. Doing multiple steps like this produced a significantly better image than just unsharpening strongly and downsizing (which is still better than nothing).

So by adding a sharpening step before saving the smaller original in case the image is really big (say you're starting with a camera upload 8k x 8k) - and then using the existing option to use sharpening when creating transforms as well would actually produce better quality images than just uploading a huge file (like it is now) and only sharpening once on transform creation.

Going even further, there could be conditional code that does multiple sharpening-downsizing passes if the image is really large, until reaching a specified desired original size (still bigger than any transforms obviously).

Support file-based config

Having the option to create transforms in the image-optimize.php config file would be a complimentary alternative to the current, matrix-style field config. This could be done by following the syntax of defaultVariants in a new array of transform options.

This would require a way to select a transform from the config file when you create the field on your asset source, so maybe a new field type could be used to select from the config file. Making the connect to the config file would allow for quick updates via the config file and it would allow for version control of these settings.

If someone deletes a transform from the array, it could fall back to the defaultVariants transform so the site doesn't break.

Separate Sizes from other Settings

It would be nice to separate the image sizes from the other settings.
We use Content builder a lot and give the user the option to say which ratio the image can be for example a slide use rather landscape and for a grid with a lot images a 1:1 ratio fit better.

In Imager we do it so:

{% set defaults = {
  cn: 'a-image',
  modifiers: [],
  data: {},
  js: null,
  waypoint: null,
  waypointAni: null,
  image: null,
  sizes: [
    { width: 1600 },
    { width: 1000 },
    { width: 500 },
    { width: 250 },
    { width: 125 }
  ],
  mode: 'crop',
  position: null,
  ratio: null
} %}
{% set images = craft.imager.transformImage(opt.image, opt.sizes, imageSettings) %}

In short. Global Image Settings would be nice and overwrites like this:

  sizes: [
    { width: 1600, 'aspectRatioX': 16.0, 'aspectRatioY': 10.0, },
    { width: 1000, 'aspectRatioX': 1.0, 'aspectRatioY': 1.0, },
    { width: 500 },
    { width: 250 },
    { width: 125 }
  ],

would be a good option.

Name conflicts with known open-source image optimizer.

ImageOptim is a well known mac and web based image optimizer built by @pornel . As far as I can tell, the craft-imageoptim plugin is not affiliated with @pornel or his products.

I recommend changing the name (to craft3-imageoptimizer?) to avoid confusion and be a good open-source citizen.

imgix API

Probably a stupid question but I noticed the addition of 'Imgix API Key' question in the Imageoptimize settings when choosing for 'transform method imgix'.

From where do I get the API key? The source details in my IMGIX dashboard don't show such an API key.

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.