Five levels of handling images in Laravel
We'll cover resizing, image optimization, and UI enhancements and show how Spatie's packages and products can make the whole process easier, more efficient, and even a bit fun.
Read more [spatie.be]
Posts tagged with image manipulation
We'll cover resizing, image optimization, and UI enhancements and show how Spatie's packages and products can make the whole process easier, more efficient, and even a bit fun.
Read more [spatie.be]
– rias.be
There might be many reasons you need to add text on top of an existing image.
Read more [rias.be]
Join thousands of developers
Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.
No spam. Unsubscribe anytime. You can also follow me on X.
We’ve released a new major version of spatie/image, v3. This package makes it very easy to manipulate images using PHP.
At the same time, we’ve also released a new major version of spatie/laravel-medialibrary. This is a powerhouse package that can associate all kinds of files with Eloquent models. The latest version of this package now uses spatie/image v3 under the hood for manipulating images.
In this blog post, I’ll explain why we made new major versions and how they can be used.
Fascinating read by Aaron Francis on how he used Netlify to generate dynamic OG images.
Read more [www.netlify.com]
– protone.media - submitted by Pascal Baljet
For Artisan School, I wanted to create custom Open Graph images for each video page. When somebody shares a link on social media, platforms like Facebook and Twitter use the OG image to represent the shared link. I'll show you how to use Browsershot and Tailwind CSS to generate and save the OG images.
Read more [protone.media]
– dev.to
Erika Heidi created a nice solution to generate and update cover images on your Twitter account. In this blog post she explains it all.
Read more [dev.to]
I'm currently organizing the Full Stack Europe conference. The first edition will be on 23 - 25 October in the beautiful city of Antwerp, Belgium. I believe that the best apps or sites aren't built by programmers. They're built by teams. That's why we designed this conference for everybody and don't stick to just one aspect of programming.
Over at Laravel News Povilas Korop wrote a nice tutorial on how to use our medialibrary (we released a new major version a couple of days ago).
By default, the Laravel registration form contains only the name, email, and password, but often it’s useful to allow the user to upload a photo or an avatar. In this tutorial we will show you an easy way to add it, using Spatie’s Media Library package.
https://laravel-news.com/uploading-avatar-images
It's a good tutorial but there's a few things not mentioned. At the end of the post you'll see this line of code:
Auth::user()->getMedia('avatars')->first()->getUrl('thumb');
That can be written a bit shorter as :
Auth::user()->getFirstMediaUrl('avatars', 'thumb');
The new v7 of the medialibrary has a new feature called "single file collections", which is just perfect for this example. Take a look at the docs: https://docs.spatie.be/laravel-medialibrary/v7/working-with-media-collections/defining-media-collections#single-file-collections
laravel-medialibrary is a powerful package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. At Spatie we use this package in nearly every project. The last few months our team has…
laravel-medialibrary is a package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. Like mentioned before on this blog my team and I are currently creating a new major version, v7,…
To convert html to a pdf or an image using wkhtmltopdf and wkhtmltoimage tends to be the popular option. Unfortunately those tools contain an outdated browser engine to do their thing, so you can't use any newish css syntax. A while ago Google added a headless mode to Chrome. They've also released a…
A while ago we released image-optimizer. In short this package can make all kinds of images smaller by stripping out metadata and applying a little bit of compression. Read this blogpost to learn more about it. Although it's pretty easy to work with the package, we felt that we could deliver a more…
Our recently released image-optimizer package can shave off some kilobyes of PNGs, JPGs, SVGs and GIFs by running them through a chain of various image optimization tools. In this blog post I'll tell you all about it. First, here's a quick example on how you can use it: use…
Browsershot is a package that can easily convert any webpage into a image. Under the hood the conversion is made possible new headless options in Chrome 59. In this post I'd like to show you how you can use Browsershot v2. Here's a quick example of how it can be used:…
Today we released a new package called image that makes manipulation images in PHP extremely easy. In this post I'd like to explain why we built it and how it can be used. Manipulating images in PHP To manipulate images in PHP there are already a lot of options. You can go hardcore and use the Gd or…
Over at Sitepoint Christoper Pitt shares some research he has done in finding differences in images using PHP.
I recently stumbled across a fascinating question: how could I tell whether an image had changed significantly? As PHP developers, the most troublesome image problem we have to deal with is how to resize an upload with an acceptable loss of quality.In the end I discovered what many before me have – that this problem becomes relatively simple given the application of some fundamental mathematical principles. Come along with me as we learn about them…
https://www.sitepoint.com/finding-differences-in-images-with-php
Today we tagged a new major version of laravel-medialibrary. In case you're not familiar with this package here's a quick rundown of what it can do. The package can associate all sorts of files with Eloquent models. It provides a simple, fluent API to work with. Here's a quick example: $newsItem =…
Glide is an easy to use image manipulation library by Jonathan Reinink. It was bumped to version 1.0.0 a few days ago. Glide can created optimized images on the fly by levering url's such as /img/users/1.jpg?w=300&h=400&fit=crop. Take a look at the example in the Glide documentation to know more.
I think Glide provides a very nice API to create image manipulations. Unfortunately it isn't very easy to use the API to generate an image using code. So I created a little package for that called laravel-glide. All new major versions of Spatie packages will require PHP 7, laravel-glide is no exception to this.
Here's an example of how to create a greyscale version image with a maximum width of 50 pixels.
GlideImage::create($pathToImage)
->modify(['filt'=>'greyscale', 'w'=> 50])
->save($pathToWhereToSaveTheManipulatedImage);
Take a look at Glide's image API to see which parameters you can pass to the modify-method.
Update added on 14th november 2017: Adding imagick on a forge provisioned server is now as simple as running sudo apt-get install php-imagick
Today I set up some PHP 7 servers on Forge. Those servers are going to be used to host some Blender based projects. Blender uses laravel-medialibrary to convert images. The package uses Imagick to do that. It turns out the Imagick PHP 7 extension isn't released yet. But there's an RC2 release candidate. Pascal Baljet provided this script to compile and install the extension.
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget http://pecl.php.net/get/imagick-3.4.0RC2.tgz
tar xvzf imagick-3.4.0RC2.tgz
cd imagick-3.4.0RC2
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0RC2*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
service php7.0-fpm restart
service nginx restart
I was a bit worried that the extension would be unstable, but all image manipulations that I need on my projects (cropping and resizing some stuff), just worked. Mandatory disclaimer: your mileage may vary.
When starting out with Laravel I made a medialibrary to associate uploaded files with models. In our custom made cms we use the medialibrary to for example associate articles with images. In short the medialibrary could: associate files with models generate thumbnails and other derived images from…