ueffel / caddy-imagefilter Goto Github PK
View Code? Open in Web Editor NEWCaddy module to transform images from the file system in various ways.
License: MIT License
Caddy module to transform images from the file system in various ways.
License: MIT License
Have you considered adding watermark to the picture? The watermark content is dynamic. Read the watermark text from the request header
http://:9000 {
header * {
-Server
}
root D:/Images
@thumbnail {
path_regexp thumb /.+\.(jpg|jpeg|png|gif|bmp|tif|tiff|webp)$
}
handle @thumbnail {
image_filter {
fit {query.w} {query.h}
}
}
file_server
}
http://localhost {
header * {
-Server
}
root * D:/Images
route {
reverse_proxy /api/operation/downfile http://localhost:205 {
@accel header X-Accel-Redirect *
handle_response @accel {
rewrite * {rp.header.X-Accel-Redirect}
header {
#To realize the download after the file name is changed, add the Content-Disposition at the bottom.
#If it is not added, it can realize the authentication before the file acquisition (through the file ID), Can be used for preview
Content-Disposition {rp.header.Content-Disposition}
Water-Mark {rp.header.Water-Mark}
}
reverse_proxy [::1]:9000
}
}
try_files {path} /index.html
file_server
}
}
# C# Code if you need I can also provide the go code
#The code returns the true path of the file through the response header. With the watermark to be added, can caddy add the #watermark to the returned image when forwarding to localhost: 9000
# public IActionResult DownFile() {
# //If the file does not exist, point to a default picture
# //return Redirect("http://localhost:8001/UserFile/notfind.jpg");
# //HttpContext.Response.Headers["Content-type"] = "application/octet-stream";
# var _fileName = HttpUtility.UrlEncode("imagerealName.jpg");
# HttpContext.Response.Headers["Content-Disposition"] = "attachment;filename=" + _fileName;
# HttpContext.Response.Headers["X-Accel-Redirect"] = "D:/Images/aaaa.jpg";
# HttpContext.Response.Headers["Water-Mark"] = "UserRealId";
# HttpContext.Response.StatusCode = 200;
# return Json("");
# }
I downloaded caddy and image-filter on January 23, 2022 when I used Examples
{
order image_ filter before file_ server
}
@thumbnail {
path_ regexp thumb /.+\. (jpg|jpeg|png|gif|bmp|tif|tiff|webp)$
query w=*
query h=*
}
image_ filter @thumbnail {
fit {query.w} {query.h}
}
The code does not respond correctly
Change to the bottom so that you can respond to the request correctly
{
order image_ filter before file_ server
}
http://localtest.xxx.cn {
root * D:/GitHub/dist
route {
reverse_ proxy /api/* http://192.168.1.123:1205
try_ files {path} /index.html
file_ server
}
@thumbnail {
path_ regexp thumb /.+\. (jpg|jpeg|png|gif|bmp|tif|tiff|webp)$
query w=*
query h=*
}
handle @thumbnail {
image_ filter {
fit {query.w} {query.h}
}
}
Download caddy, image-filter and cache in the introduction again
Error in code in Advanced Configuration after enabling cache
{
order image_ filter before file_ server
order cache before rewrite
}
http://localtest.xxx.cn {
root * D:/GitHub/dist
route {
reverse_ proxy /api/* http://192.168.1.123:1205
try_ files {path} /index.html
file_ server
}
@thumbnail {
path_ regexp thumb /.+\. (jpg|jpeg|png|gif|bmp|tif|tiff|webp)$
}
handle @thumbnail {
reverse_ proxy [::1]:9000 # prevents multiple "Server: Caddy" response header
}
}
http://:9000 { # internal address only accessable from the server itself to transform images
bind ::1 # local ipv6 address (same as 127.0.0.1 for ipv4)
#cache {
#ttl 1000s
#}
#header Cache-Control "max-age=86400" # keep 1 day in cache
root D:/GitHub/dist
@thumbnail {
path_ regexp thumb /.+\. (jpg|jpeg|png|gif|bmp|tif|tiff|webp)$
}
handle @thumbnail {
image_ filter {
fit {query.w} {query.h}
}
}
}
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.