Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Thank you 🙏

I had a chance to get back to working on experimenting with the ImgProxy server and I have a question:

Suppose I have the following part of the content model:

"assets": { // assets is a part of another general model
  "baseUrl": "https://{my.cdn.host}/c/e/B_SP", // misc
  "thumb":  {
    "src": "https://{my.cdn.host}/c/e/B_SP/thumb.jpg", // original image (only for reference)
    "srcset":  [ // these are generated by the backend on-the-fly upon request
      {
        "url": "https://{server.gen.signed.imgproxy.url}/fn:thumb_1x/{other}/thumb.jpg", // results in thumb_1x.jpg or whatever the extension is
        "x": 1,  
        "w": 128
      },
      {
        "url": "https://{server.gen.signed.imgproxy.url}/fn:thumb_2x/{other}/thumb.jpg", // same
        "x": 2,
        "w": 256
      }, // ..etc based on dpi requirements
    ]
  },
}

Problem Space:

I want to be able to generate the srcset on the fly, but I don't want to store the images in the blob storage, I want to be able to generate them on the fly and cache them on the CDN.

Background:

Given I have my blob storage configuration, my server is able to programatically able to determine
the file name, there like 3 - 5 different file names that I need to generate, but the config
for imgproxy is the same, the only thing that changes is the file name.

Question:

Does ImgProxy support renaming the output file in the HTTP response? For example, can ImgProxy return a processed image with a URL ending in thumb_1x.jpg while the actual source file remains thumb.jpg in the storage? Is this renaming just a URL convention, or does it reflect in the HTTP response headers (e.g., in the Content-Disposition header)?

The following is within the docs:

filename:%filename:%encoded
fn:%filename:%encoded

So I suppose I can use the filename option to rename the file,
but I am not sure if I'm applying transformation correctly.

Here's the req to my local imgproxy server:

http://localhost:8080/BaXyTjATDUtsKBK2KLOcv3jpin-uUWOvvKGgj3GuNzI/rs:fit:400:0:0/g:ce/fn:test/plain/local:///ex/C/extraLarge.png

Response Headers:

HTTP/1.1 200 OK
Cache-Control: max-age=31536000, public
Content-Disposition: inline; filename="test.avif"
Content-Length: 12289
Content-Security-Policy: script-src 'none'
Content-Type: image/avif
Expires: Thu, 28 Nov 2024 01:57:49 GMT
Server: imgproxy
Vary: Accept
X-Request-Id: VxMbNw2jcrvRe2uL4mjzR
Date: Wed, 29 Nov 2023 01:57:49 GMT

Request Headers:

GET /BaXyTjATDUtsKBK2KLOcv3jpin-uUWOvvKGgj3GuNzI/rs:fit:400:0:0/g:ce/fn:test/plain/local:///ex/C/extraLarge.png HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Pragma: no-cache
Cache-Control: no-cache

The Content-Disposition: inline; filename="test.avif" is set properly.

The response has the same file name as the source file, so I am doing something wrong?

You must be logged in to vote

I was wondering if it's possible to rename the transformed file;

But, I think I'm just on the wrong path overall & might not even need this.

Replies: 1 comment · 1 reply

Comment options

Hey @vinclou!

Sorry, but I don't really understand what you're trying to achieve. Could you explain what you mean by response filename? The only filename HTTP response can have is one specified in the Content-Disposition header, and this is exactly what the filename option changes.

You must be logged in to vote
1 reply
@vinclou
Comment options

I was wondering if it's possible to rename the transformed file;

But, I think I'm just on the wrong path overall & might not even need this.

Answer selected by vinclou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.