• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Reformating images with App::BlurFill

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
You might know that I publish books about Perl at

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

. What you might now know is that I also publish more general technical books at

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

. If you scroll down to the bottom of that page, you’ll see a list of the books that I’ve published. You’ll also see evidence of the problem I’ve been solving this morning.

Books tend to have covers that are in a portrait aspect ratio. But the template I’m using to display them requires images in a landscape aspect ratio. This is a common enough problem. And, of course, we’ve developed a common way of getting around it. You’ll see it on that page. We create a larger version of the image (large enough to fill the width of where the image is displayed), apply some level of Gaussian blur to the image and insert a new copy of the image over that. So we get our original image with a tastefully blurred background which echoes the colour of the image. ChatGPT tells me this is called a “Blurred Fill”.

So that’s all good. But as I’m publishing more books, I need to create these images on a pretty regular basis. And, of course, if I do something more than three or four times, I will want to automate.

A while ago, I wrote a simple program called “

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

” that used

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

to apply the correct transformations to an image. But this morning, I decided I should really make that program a bit more useful. And release it to CPAN. So that’s what I’ve been doing.

The Problem


Adjusting images to fit various aspect ratios without losing essential content or introducing unsightly borders is a frequent challenge. Manually creating a blurred background for each image is time-consuming and inefficient, especially when dealing with multiple images or integrating into automated workflows.

The Solution: App::BlurFill



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

is a Perl module and CLI tool designed to streamline the process of creating images with blurred backgrounds. It takes an input image and generates a new image where the original is centred over a blurred version of itself, adjusted to the specified dimensions.

How It Works

  1. Input : Provide the source image along with the desired width and height.
  2. Processing:
    • The tool creates a blurred version of the original image to serve as the background.
    • It then overlays the original image, centred, onto this background.
  3. Output: A new image file with the specified dimensions, combining the original image and its blurred background.
Installation and Usage


Install via CPAN:


cpanm App::BlurFill

Then to use the CLI tool:


blurfill --width=800 --height=600 input.jpg

This command will generate input_blur.jpg with the specified dimensions.

Web API


App::BlurFill also includes a web interface built with Dancer2. You can start the web server and send POST requests with an image file to receive the processed image in response.

Example using curl:


curl -OJ -X POST

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

-F "image=@input.jpg"

The response will be the new image file, ready for use.

Under the Hood


App::BlurFill is written in Perl 5.40, using the new

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

feature. It makes use of the Imager module for image processing tasks. Currently, it supports JPG, PNG and GIF.

What’s Next?


Future enhancements may include:

  • Support for modern image formats like WebP.
  • More customisation options.
  • A Docker container to make it easier to set up and use.
  • Maybe a hosted version. Maybe it’s even a business idea.

App::Blurred aims to simplify the task of creating visually consistent images across various platforms and devices. Feedback and contributions are welcome to help improve its functionality and usability.

Please let me know if you find it useful or if there are extra features you would find useful.

Oh, and why not buy some

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

books!

The post

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

first appeared on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу