Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Humam Abo Alraja
    This is my kotlin implementation
        fun generateSignedUrl(
            key: ByteArray,
            salt: ByteArray,
            url: String,
            preset: String,
            resize: String,
            width: Int,
            height: Int,
            enlarge: Int,
            gravity: String,
            extension: String?,
        ): String {
            val encryptionAlgorithmKey = "HmacSHA256"
            val encodedUrl: String = Base64.getUrlEncoder().withoutPadding().encodeToString(url.toByteArray())
            val path = "preset:$preset/resize:$resize:$width:$height:$enlarge/gravity:$gravity/$encodedUrl"
            val encryptionAlgorithm: Mac = Mac.getInstance(encryptionAlgorithmKey)
            val secretKey = SecretKeySpec(key, encryptionAlgorithmKey)
            val hash: String = Base64.getUrlEncoder().withoutPadding().encodeToString(encryptionAlgorithm.doFinal(path.toByteArray()))
            val imageProxyInstanceURL = ConfigProvider.getConfig().getValue(IMAGE_PROXY_INSTANCE_URL, String::class.java)
            return "$imageProxyInstanceURL/$hash/$path"
        fun stringToByteArray(hex: String): ByteArray {
            val hexLength = hex.length
            val data = ByteArray(hexLength / 2)
            var i = 0
            while (i < hexLength) {
                data[i / 2] = ((Character.digit(hex[i], 16) shl 4) + Character.digit(hex[i + 1], 16)).toByte()
                i += 2
            return data
        fun getResizedURL(url: String, width: Int, height: Int): String {
            val key: ByteArray = stringToByteArray("KEY_VALUE")
            val salt: ByteArray = stringToByteArray("SALT_VALU")E
            val preset = "sharp"
            val resize = "fill"
            val gravity = "no"
            val enlarge = 0
            return generateSignedUrl(key, salt, url, preset, resize, width, height, enlarge, gravity, extension = null)
    Sergey Alexandrovich
    Hey @humamaboalraja! It looks like you need to add a slash (/) to the beginning of path. Here's the explanation of how URLs can be signed: https://docs.imgproxy.net/signing_the_url
    Owen Banan
    Hey guys. I've setup imgproxy in homestead and it seems like my app cant reach the imgproxy server
    anyone knows what am I missing ?
    Ive set the env IMGPROXY_BASE_URL=
    Sergey Alexandrovich
    Hey @owenbanan-cp. Sorry, it’s not enough info to say something. How is imgproxy installed? How is your app installed? Why do you think your app can’t reach imgproxy? What errors do you see?
    Also, I believe you’re using IMGPROXY_BASE_URL wrong way. Please, check the documentation.
    Owen Banan
    @DarthSim I installed the imgproxy using this command "docker pull darthsim/imgproxy:v2.15.0"
    Using the command to run the docker
    docker run --add-host=drybrush.dev.com: -p 8081:8080 --env IMGPROXY_MAX_SVG_CHECK_BYTES=100000 --env IMGPROXY_MAX_SRC_RESOLUTION=100 --env IMGPROXY_ENFORCE_WEBP=true --rm -it darthsim/imgproxy:v2.15.0
    Sergey Alexandrovich
    @owenbanan-cp Everything looks fine. When you open http://localhost:8081 in your browser, what do you see?
    Owen Banan
    @DarthSim page can't reach
    By the way. Im running the container in VM
    Owen Banan
    Ohhh. I manage to run it already. I need to use the IP of my VM
    Thanks for the response. just realized it.
    Hello! Can you specify the DPI of the output image? Like 300dpi
    And also, can you set the color mode? Like RGB or CMYK
    @DarthSim couldn't find anything on the docs
    Sergey Alexandrovich
    Hey @seratz! You can't specify either DPI or the resulting color mode. If imgproxy is configured to strip metadata, DPI will be reset to 72. It will stay unchanged otherwise. Same for color mode: the image will be converted to sRGB if imgproxy is configured to strip ICC. Otherwise, the color mode will stay the same.
    Could you describe your use case where you need these options?
    Our software is used by marketing teams, and sometimes they need to crop an image, or make an adjustment in sizing to rapidly generate an image to send to the printer. It's not really that frequent, because those tasks generally needs to pass through Photoshop or something like that. But if the user has the option, it may be a good fit for some quick work.
    1 reply
    I deployed the imgproxy Helm chart to my Rancher k8s cluster, mostly with default settings. Now the service name is "imgproxy-imgproxy-imgproxy". I'd like to change that to simply imgproxy, and tried by setting fullnameOverride in values.yaml, but it doesn't seem to get picked up. Is this the right property to set?
    2 replies
    I just got an error 422, saying "Can't download source image: Source image resolution is too big" - what can I do about that?
    Sergey Alexandrovich
    @gunnarschmid increase IMGPROXY_MAX_SRC_RESOLUTION
    1 reply
    Temba Mazingi
    Hello, I have successfully deployed imgproxy to an instance of Google Cloud Run. I am to serve and resize any public image online except for the target images I need to serve from a publicly readable Google Cloud Storage bucket. I understand that I need to set IMGPROXY_USE_GCS to true and provide a value for IMGPROXY_GCS_KEY, I am just unsure about how to go about doing this. Any assistance with how to get this setup completed would be greatly appreciated. Thanks!
    1 reply
    Humam Abo Alraja
    Hi everyone, is there any documentation for caching and how to enable it on AWS or your instance's disk cause after I set up the instance everything regarding signing the URL is working, but on each request, it's re-compressing/resizing the image which is causing heavy load time
    2 replies
    Humam Abo Alraja
    Did anyone use a CDN or caching layer with imgproxy before, and if so what's the best way you suggest to do that, thanks in advance
    I'm thinking my processing time is slow. My images are not that big, like 2800 x 1400. I generate thumbnails in batch of 30 images in a row. webp/320x240. The first 5 finishes in avg 500 ms, but then it starts cascating and the last images are taking like 3,4,5 seconds to finish. I have 2CPU/4GB RAM exclusive for this instance. Concurrency is default.
    What avg speed should I aim to in optimizing? 500ms per image?
    Sergey Alexandrovich
    @seratz The default concurrency for 2CPU is 4, which means that only 4 images can be processed simultaneously. If you request 30 images same time, imgproxy will need to process ceil(30 / 4) = 8 batches of images. If the processing of a single image takes about 500 ms, then processing of all 30 will take ~4 seconds.
    The resizing speed highly depends on the source image format. JPEG, WebP can be scaled on load which makes their resizing very fast. But most formats like PNG, AVIF, or HEIC can't be scaled on load.
    Meunier-De Mot Cedric
    I would like to generate a url with signature + plain but I always have Invalid signature. And I don't understand. example of my code:
    key = bytes.fromhex("XXXX")
    salt = bytes.fromhex("XXXX")
    url = 'https://www.nasa.gov/sites/default/files/thumbnails/image/pia22228.jpg'
    path = "/resize:{resize}:{width}:{height}/gravity:{gravity}/plain/{url}".format(
    digest = hmac.new(key, msg=salt+path, digestmod=hashlib.sha256).digest()
    protection = base64.urlsafe_b64encode(digest).rstrip(b"=")
    url = b'/%s%s' % (
    Sergey Alexandrovich
    Hey @cedrichelloasso! I tried your code, and it works just fine. Make sure you provide the same key/salt pair to the imgproxy server and your instance.
    Meunier-De Mot Cedric
    @DarthSim I just realised that it works locally, but not on a remote server with the same code and settings. I'll look for it, sorry for the inconvenience.
    Colleen Schnettler
    @DarthSim I submitted a PR back in January to use Wasabi URLs - do you think it will be merged? imgproxy/imgproxy.rb#166
    Hello :)
    I have this PHP script for generating a signed URL to an object in s3, and it works really well. But I cannot for the life of me get it to work with versioning turned on in the bucket. Anyone got some experience with this?
    I'm trying to do it as outlined in the docs here: https://github.com/imgproxy/imgproxy/blob/master/docs/serving_files_from_s3.md
    $key = "...";
    $salt = "...";
    $keyBin = pack("H*", $key);
    if (empty($keyBin)) {
        die('Key expected to be hex-encoded string');
    $saltBin = pack("H*", $salt);
    if (empty($saltBin)) {
        die('Salt expected to be hex-encoded string');
    $resize = 'fill';
    $width = 500;
    $height = 300;
    $gravity = 'no';
    $enlarge = 1;
    $extension = 'png';
    $instance_url = "https://img.example.com";
    $url = 's3://com.example.img/space.png'; // current version, works
    // $url = 's3://com.example.img/space.png?versionId=KXRx35DUyvuXG6KwpkK5W9bqIGtRevVN'; // v1 (doesn't work)
    // $url = 's3://com.example.img/space.png?versionId=TE9dA9ge2J5t7J0uiWyadGuh7zKt1hhh'; // v2/current (doesn't work)
    $encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
    $path = "/rs:{$resize}:{$width}:{$height}:{$enlarge}/g:{$gravity}/{$encodedUrl}.{$extension}";
    $signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin . $path, $keyBin, true)), '+/', '-_'), '=');
    echo "{$instance_url}/{$signature}{$path}" . PHP_EOL;
    1 reply
    Fredrik Rambris
    Is it possible to allow unsigned requests to a specific set of profiles while at the same time allowing signed requests to request any size or processing? So thumbnails etc in standard format can be requested without signature. Preferably with a IMGPROXY_BASE_URL set.

    Hi Team, thank you for this amazing library. Two questions when someone has a moment please --

    1. How do I make it so that the size of the downloaded image file (w x h) gets determined by css, rather than explicitly defining parameters like rs:fill:300in the url? In other words, is it possible to download the appropriate image file/size based on css/rendered size? Not sure if this may be relevant at all, but I'm trying to use this inside Next.js

    2. Is there any documentation on limitations such as bandwidth, rates, etc?

    3. What's the benefit of serving files from Google Cloud Storage buckets via setup vs just using the urls directly (firebase storage)?

    Youval Teboul
    Hi, I'm using v2 and recently I'm getting a lot of timeouts but I don't know how to debug to find the origin of the problem.
    The debug mode doesn't help me :(
    Sergey Alexandrovich
    Hey @youvalteboul! There are lots of things that can lead to timeouts. If you could show your config and some samples of timeouted requests, maybe we could figure something out.
    Youval Teboul
    @DarthSim je pense que le problème ne viens pas d'imgproxy mais de l'image source qu'on arrive pas à télécharger
    Hi, I tried to upload a png file with % in the namefile. I have a Source is unreachable error but when I remove the % in my filename it, works. http://localhost:9999/insecure/rs:fit:300:200:0/plain/local:///uniqlo27(5%).png@png
    How can we validate the filename with % using img-proxy ?
    Does any one know how to use the Object Detecion and which data should I set in IMGPROXY_OBJECT_DETECTION_CONFIG ?
    Sergey Alexandrovich
    @taibui324 you need to escape %, ?, and @ in your source URLs. In your particular case, just replace % with %25
    Sergey Alexandrovich

    @YiChia If face detection is enough for you, just use imgproxy Pro images tagged with the -ml suffix. Like v3.5.0-ml.
    If you want to provide a custom model to imgproxy, it’s a bit more complex thing. First, you need a model. Imgproxy Pro uses Darknet YOLO model. You can download an already trained model or you can train your own. A YOLO model is three files: a model config file, a model weights file, and a model class names file (basically, a text file with class names one by line).
    Next, you need to put this files into imgproxy container. There are two ways to do so. The first one is to mount a directory with the model files to the container. But not all serverless platforms allow to do so. The second way is to build a custom image on top of imgproxy Pro image and include your model files there.

    The final step is to configure imgproxy to use your model. The variables are described here.

    If you have more questions, please drop us an email to imgproxy@evilmartians.com with the description of what you’d like to achieve, and we’ll figure something out.

    2 replies
    Hi, I would like to compile imgproxy to works on Windows. So I launched a command line and writing : "go build server.go" but an error occured : "reuseport\listen_no_reuseport.go:14:3: undefined: log" what should I do ?
    Christian Säum
    Hello guys, I have the imgproxy running successfully with Docker and Traefik.
    How can I prevent someone else from using it for themselves?
    So that only my shops can access it?
    2 replies
    Sergey Alexandrovich
    Hi @alexh67! I'm not sure Windows build is possible. I'd recommend you use our Docker image.
    Hi how can i hide the text from index page or rewrite them?
    Oleg Postoev
    Is it possible to limit of possible sizes (height, width) and quality and other. For example with steps as 10 for this values and define range of it.
    How to resolve a possible ddos attack at my server?
    We have an app that has a bunch of imgproxy images being generated via a microservice we no longer control, so we've spun up a temporary imgproxy service on a subdomain. But the URL format doesn't seem to work anymore. The old proxy service had URLs formatted like this: https://imgproxy.domain.net/insecure/fit/90/90/sm/0/plain/https://foobar.com/ipsum.png
    But when trying that format in the new container we spun up, I'm getting an "Invalid URL" error. I'm guessing the URL format got changed between versions. Is there a way to use the old format without jumping through a bunch of hoops? If not, what is the last version that used the old format? there's too many places in the app to refactor to the new format at the moment
    2 replies
    Francis Hwang
    Hi, what are the recommendations for signing a URL in the browser? If you give both your key and your salt to the browser, as is done here (https://github.com/progapandist/imgproxy-form/blob/gh-pages/index.js), it would be possible for an attacker to retrieve them and use them, right?
    3 replies