Comments (5)
Thanks for the thoughtful response @jvahldick . We have been using RESULT_STORAGE and I agree that it is useful even when serving behind a CDN, for many of the reasons you've mentioned. I'll close this issue.
from imagor.
Result Storage
is kinda the equivalent of caching, so yes a CDN would be more well suited for caching the processed image.
However some people had wanted to retrieve the processed image files, where Result Storage
comes in handy other than caching. So Result Storage
is just one of the option, and the benefits depends on the use case.
from imagor.
Hi @cshum , thank you for the response, that all makes sense. Does writing to Result Storage
impact latency for the first requester of an asset, or does it happen in the background?
from imagor.
Hope you don't mind me high jacking this question, but mine is of a similar thread.
I'm considering moving away from thumbor and saw this project. The only question i have is if you support Redis for the result storage, or if you have plans to add it in the future?
from imagor.
I would like to give my opinion regarding your first question. In my perspective, the ResultStorage is quite useful, and I'm using imagor behind the CDN. Imagine the scenario where you have a multi-layer processing for the images. Eg: image with 5 watermarks
So, filters(watermark:...) of a filters(watermark:...)
At some point, it fails. Unfortunately, I do not remember exactly all the issues I faced. I think one was related to not being able to have multiple parameters or something like this. The other one was related to the S3 limiting it (#153)
Another benefit I see on the ResultStorage is that it looks for the images on the bucket, so we do not necessarily need to have quite long URLs. So, instead watermark(https://full-url/image.jpg) you can have /image.jpg
Regarding perfomance, I don't think it has any impact.
https://github.com/cshum/imagor/blob/c11b178d4544ed1cd2870fd33fe57a39840dc1a9/imagor.go#L423-L425C4
Lines 444 to 460 in c11b178
Did you try to run it without setting the ResultStorage? Unless it is required, I do not really think it has an impact there.
@kiithwarrior
The CDN would do a better job IMHO.
If for some reason you cannot use a CDN, I think one option is to proxy imagor, and if the request is sucessful you can know the name of the ResultStorage filename. I'm doing something similar
PHP example:
private const PATH_REGEX =
'\/*' .
// meta
'(meta\/)?' .
// trim
'(trim(:(top-left|bottom-right))?(:(\\d+))?\/)?' .
// crop
'(((0?\\.)?\\d+)x((0?\\.)?\\d+):(([0-1]?\\.)?\\d+)x(([0-1]?\\.)?\\d+)\/)?' .
// fit-in
'(fit-in\/)?' .
// stretch
'(stretch\/)?' .
// dimensions
'((\\-?)(\\d*)x(\\-?)(\\d*)\/)?' .
// paddings
'((\\d+)x(\\d+)(:(\\d+)x(\\d+))?\/)?' .
// h_align
'((left|right|center)\/)?' .
// v_align
'((top|bottom|middle)\/)?' .
// smart
'(smart\/)?' .
// filters
'(filters:(.+?\\))\/)?' .
// image
// '(.+)?'
'(?P<imagePath>.+)?'
;
// We need to get the Imagor secret and create the suffix which is generated by imagor when creating images
// eg: /path/original.{suffix}.extension
$path = $uri->getPath();
$digest = sha1(ltrim($path, '/'));
$hash = substr($digest, 0, 20);
$endpoint = $this->concatenateUriParts(
...,
...,
$this->createSuffixedImagePathHash($path, $hash),
);
function createSuffixedImagePathHash(string $path, string $hash): string
{
$imagePath = $this->getImagePathFromPath($path);
$fileExtension = pathinfo($imagePath, PATHINFO_EXTENSION);
if ($fileExtension === '') {
return sprintf('%s.%s', $imagePath, $hash);
}
$dotIdx = strrpos($imagePath, sprintf('.%s', $fileExtension));
$filenameWithoutExtension = substr($imagePath, 0, $dotIdx);
// In case there is a format filter, we should look over it as the extension of the file changes
$pattern = "/.*format\((.*?)\)/";
preg_match($pattern, $path, $output);
if (!empty($output[1]) && $output[1] !== '') {
$fileExtension = $output[1];
}
return sprintf(
'%s.%s.%s',
$filenameWithoutExtension,
$hash,
$fileExtension
);
}
function getImagePathFromPath(string $path): string
{
preg_match('/' . self::PATH_REGEX . '/', $path, $matchedValues);
if (key_exists('imagePath', $matchedValues) && $matchedValues['imagePath'] !== '') {
return $matchedValues['imagePath'];
}
return $path;
}
from imagor.
Related Issues (20)
- Feature request: Image Presets
- Default domain feature: Allow secondary domain HOT 2
- Example of Signature in Go? HOT 1
- Multi-frame images (gif, tiff) and max height calculation
- Feature Request: Option to exclude /healthcheck from access logs HOT 1
- Feature request: color specific `meta` information
- use default quality,avif image size too large
- returning response headers from origins HOT 9
- round_corner filter fails for bmp images
- fill(none) fails on a grayscale image HOT 2
- CR2 support
- Thumbnail Extraction from .mov Issue HOT 1
- Feature Request: Header Auth Support? HOT 2
- Does not save watermark in FILE_STORAGE_BASE_DIR HOT 6
- Using font HOT 1
- NEF format poor quality
- Feature: watermark support text HOT 3
- Image processing on GPU HOT 1
- What it's for imagor HOT 1
- Corrupted images in "file_result_storage" directory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imagor.