imgix / imgix-php Goto Github PK
View Code? Open in Web Editor NEWA PHP client library for generating URLs with imgix
Home Page: https://www.imgix.com
License: BSD 2-Clause "Simplified" License
A PHP client library for generating URLs with imgix
Home Page: https://www.imgix.com
License: BSD 2-Clause "Simplified" License
Is there any way to get the desired image height and width before sending html response? We need this feature for image gallery section. Thanks
Right now, the composer.lock
file is committed to the repo. This is usually not done for packages, because it locks it to the PHP version of the person generating the lock file. (See bottom of file)
I think the removal of this file could solve the problem where you have to run composer update
in CI as well. Since if the lock file is missing, a new one will be generated upon running composer install
. This will happen for each version of PHP in the matrix, letting Composer install the latest packages compatible with the current PHP version.
The lock file is not used when installing this as a package in a project in any case.
Hope you understand my ramblings! 😅
Popular packages without composer.lock files:
Every time there is an umlaut in the path, the created secret doesn't match and the Imgix will not show the image.
$path = '/files/2013/11/Daniel_Müller-Jan.jpg';
$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params);
$path = '/files/2013/11/Daniel_Müller-Jan.jpg';
$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params, true);
(raw)urlencode
the path.
$path = rawurlencode('/files/2013/11/Daniel_Müller-Jan.jpg');
$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params);
When i pass height (h) and width (w) parameter to createSrcSet
function then the width is taken into account in the sourceSet but the height is not adjusted, as is the case in the imgix.js library.
https://github.com/imgix/imgix.js/blob/main/src/ImgixTag.js#L161
To Reproduce
Call createSrcSet
with the parameter ['w' => 1000, 'h' => 500]
.
The current result looks like this:
image.jpg?h=500&w=100 100w
image.jpg?h=500&w=116 116w
image.jpg?h=500&w=134 134w
image.jpg?h=500&w=156 156w
.
.
.
Expected behavior
The expected result should look like this:
image.jpg?h=50&w=100 100w
image.jpg?h=58&w=116 116w
image.jpg?h=67&w=134 134w
image.jpg?h=78&w=156 156w
.
.
.
Information:
Additional context
Especially when working with focalPoints, it is important to specify the width together with the height. It is then not enough to pass only the width.
Is this Library support this :
https://docs.imgix.com/tutorials/multiline-text-overlays-typesetting-endpoint.
If yes , how to use it?
Question : I want to show text on image with overlay effect
Is it possible to add multiline text using this?
Related to https://github.com/imgix/js-core#fixed-image-rendering
Add a devicePixelRatios
option to the https://github.com/imgix/imgix-php#fixed-width-images function to allow users to customize the target device pixel ratio(s) (dpr
) when generating a fixed image. This will allow users to have more granular control over the fixed-size srcset values generated.
Hello!
Right now it is not possible to set a param to a value of zero. It just doesn't show up on the generated URL.
There are some scenarios where you would like to set a param to 0 (zero). One example being:
With PHP 7.4 reaching end of life in a couple of days, it could be a good opportunity to release a new major version with only PHP 8.0+ support. This would allow for easier contribution without having to worry about older unsupported and insecure versions. composer.json
currently declares support for PHP 7.3 and above. And there's a reference to PHP 7.1 in a code comment.
People stuck on older PHP versions could continue using 3.x until they can upgrade.
I believe that the public APIs should be kept with minimal changes, and could benefit from some type hints, return types and other goodies.
(Most important of all, replace the hideous array()
s with []
😅)
Current release 3.3.1 is from march 2021.
It would be nice if the new changes in master are added maybe in a minor 3.3.2 or maybe 3.4.
Here's the parameters I am trying to use to build the image:
return [
'balph' => 100,
'bx' => 300,
'bm' => 'normal',
'markpad' => 0,
'mark' => [
'statics/watermarks/watermark_first_pic.png' => [
'bm' => 'normal',
'by' => 872,
'bx' => 310,
'blend' => [
'~text' => [
'txtclr' => 000,
'txtsize' => 44,
'txt' => '%EXPERT_CODE%#'
]
]
]
],
'w' => 1600,
'fit' => 'crop',
'h' => 1200,
'auto' => 'compress,enhance,format'
];
However this is the result:
ErrorException thrown with message "rawurlencode() expects parameter 1 to be string, array given"
Stacktrace:
#25 ErrorException in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlHelper.php:46
#24 Illuminate\Exception\Handler:handleError in <#unknown>:0
#23 rawurlencode in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlHelper.php:46
#22 Imgix\UrlHelper:getURL in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlBuilder.php:63
#21 Imgix\UrlBuilder:createURL in /home/vagrant/Code/cmarcia_gestionale/vendor/nasyrov/laravel-imgix/src/Imgix.php:36
#20 Nasyrov\Laravel\Imgix\Imgix:createUrl in /home/vagrant/Code/cmarcia_gestionale/app/modules/Watermark/Builder.php:21
#19 Watermark\Builder:buildUrl in /home/vagrant/Code/cmarcia_gestionale/app/Models/MAV.php:127
#18 Cambiomarcia\Models\MAV:getExportPhotos in /home/vagrant/Code/cmarcia_gestionale/app/controllers/UsersController.php:162
#17 UsersController:showUser in <#unknown>:0
#16 call_user_func_array in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:231
#15 Illuminate\Routing\Controller:callAction in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:93
#14 Illuminate\Routing\ControllerDispatcher:call in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:62
#13 Illuminate\Routing\ControllerDispatcher:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:967
#12 Illuminate\Routing\Router:Illuminate\Routing\{closure} in <#unknown>:0
#11 call_user_func_array in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Route.php:109
#10 Illuminate\Routing\Route:run in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1033
#9 Illuminate\Routing\Router:dispatchToRoute in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1001
#8 Illuminate\Routing\Router:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
#7 Illuminate\Foundation\Application:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:745
#6 Illuminate\Foundation\Application:handle in /home/vagrant/Code/cmarcia_gestionale/app/Middlewares/Routing/DisabledRoutes.php:19
#5 Cambiomarcia\Middlewares\Routing\DisabledRoutes:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Session/Middleware.php:72
#4 Illuminate\Session\Middleware:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php:47
#3 Illuminate\Cookie\Queue:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php:51
#2 Illuminate\Cookie\Guard:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
#1 Stack\StackedHttpKernel:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:641
#0 Illuminate\Foundation\Application:run in /home/vagrant/Code/cmarcia_gestionale/public/index.php:62
I am having an issue with the URL encode.
If I have an image with a filename like this
some-name (1).png
the library generate a URL like this
some-name+%281%29.png
and this give me a 404 error in Imgix.
Does somebody know about this bug?
Thank you
nbl7
A bug slipped through the tests in to the release. From a quick glance I think it is about empty paths.
Uninitialized string offset: 0 in imgix/imgix-php/src/Imgix/UrlHelper.php at 25
According to the documentation about purging images it shows an example for purge via Python, but it seems that there is no example in PHP or a method in this SDK library that implements this in a easy way
It is clear that must obey 3 conditions:
In Curl is using like:
curl "https://api.imgix.com/v2/image/purger" \
-u "$API_KEY:" \
-d "url=$URL_TO_PURGE"
I've just installed via a repo .zip download (024a937)...
All images in my templates work as expected. Unfortunately, the images in my posts are being mangled.
Without the plugin enabled, the img element is being modified by WP to include a srcset attribute.
This seems to be being parsed incorrectly once the imgix plugin is enabled.
I'm hoping somebody has seen this before???
Post "source":
<img class="alignnone size-full wp-image-1483" src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png" alt="Imgix - CDN" width="640" height="320" />
HTML page source with imgix plugin disabled:
<img src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png" alt="Imgix - CDN" width="640" height="320" class="alignnone size-full wp-image-1483" srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png 640w, https://getstream.io/blog/wp-content/uploads/2016/11/image01-300x150.png 300w, https://getstream.io/blog/wp-content/uploads/2016/11/image01-610x305.png 610w" sizes="(max-width: 639px) 98vw, (max-width: 1199px) 64vw, 640px" />
HTML page source with imgix plugin enabled:
<img src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px" srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&dpr=2 2x, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&dpr=3 3x," srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&dpr=2 2x, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&h=150&auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&h=305&auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&dpr=3 3x," />
I think you should add a code formatter to the project, like PHP-CS-Fixer or Laravel Pint (build on top of PHP-CS-Fixer).
Would make it easier to contribute without having to worry about code style.
I have used the module imgix in drupal which has dependency of composer. I have installed everything successfully in my localhost. I have found imgix-php files are installed in the vendor directory. I want add all the files of imgix-php inside vendor directory to git. Because I will pull all the source of vendor directory in the production server from github. So I need to push them in repo from localhost but I can't do it. Could you tell me how to add all the file imgix-php at git and push them into my repo?
I want to implement Imgix module in Drupal 7. I am working through FTP. Can anyone implemented in Drupal has better idea.
Thank You!
Related to https://github.com/imgix/js-core#variable-qualities
Add a variable_qualities
option to the https://github.com/imgix/imgix-php#fixed-width-images function to allow users to override the mapping of the quality parameter (q
) to each device pixel ratio (dpr
). This will allow users to have more granular control over the fixed-size srcset values generated.
Hello, can you please tag a release? Using Composer with dev-master
is highly discouraged. You'll even get a warning if you try to install this package using the command line:
composer require imgix/imgix-php
[InvalidArgumentException]
Could not find package imgix/imgix-php at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability
Related PR: imgix/js-core#314
Add disablePathEncoding
functionality to the URL building logic in formatPath
. This way, users can decide to opt-out of path encoding.
Probably a good way of handling this would be to add a new option, disablePathEncoding
, in the constructor that can be referenced in any of the instance methods. Specifically, createURL
, createSrcSet
., createSrcSetPairs
, createDPRSrcSet
all need to pass this option down to the URLHelper
.
Hi Guys,
I'm having the most bizarre issue. I added this package using Composer and it just simply wont appear in my Git staged files. In other words I can't commit the package even though it's there on my local machine to my Git repo for deployment.
Any ideas?
I've tried removing and adding again.
/Stefan
One of our customers ran into an issue where they accidentally provided a path component to a domain name when initializing an Imgix\UrlBuilder
.
We should validate and sanitize these, failing as early as possible if necessary.
To make larger changes I would suggest not merging such PRs directly into main
, since you have this in the readme:
{
"require": {
"imgix/imgix-php": "dev-main"
}
}
This could mean that people have the main branch running directly in their apps, and that this would break while merging PRs with breaking changes.
Could we add a setter for the $includeLibraryParam
as well?
Either public function excludeLibraryParam()
which sets $includeLibraryParam
to false, or public function setIncludeLibraryParam($includeLibraryParam)
.
Right now, the constructor gets quite long and unreadable if you want to exclude the library parameter:
$builder = new UrlBuilder("example.imgix.net", true, "1234", null, false);
I wanted to discuss the addition first, but I'm happy to make a pull request.
I needed to add PHP support for http_build_url(). This might not be an issue for anyone else but it took me a while to track down and solve. Used this:
https://github.com/jakeasmith/http_build_url/blob/master/src/http_build_url.php
in UrlBuilder::createURL, line 46 in the file, crc32($path) will often return a negative number, making $this->domains[$index] in line 48 return a blank, resulting in broken URLs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.