I want to upload a single image and resize it in 3 sizes.

Archived from the Transloadit support forum. Originally posted on October 20, 2010; details may be outdated, see our docs for current behavior. Original thread

Suppose I want to upload an images and re size this images in 3 of following sizes.

100X100
300X300
500X500

I tried Json combination But I’m not able to re-size it, I got the last re-sized image. Following is my jsoncode.

{"steps": {
       "resize_image": {
              "robot": "/image/resize"
                , "width": 45
                , "height": 45
        },
       "resize_image": {
            "robot": "/image/resize"
            , "width": 300
            , "height": 300
        },
       "resize_image": {
            "robot": "/image/resize"
            , "width": 500
            , "height": 500
            , "result": false
    
        }
      }
}

Please guide me how to solve this issue.

Hey, I looked at your assembly and this is what I think needs changing:

  • Each step needs a unique name, otherwise you are just re-assigning a different instruction over and over
  • You need to specify "use": ":original" for each step so it is using the original upload file, instead of the result of the previous step.

I made some changes to your assembly that should probably do the trick:

{"steps": {
   "size_45": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 45
    , "height": 45
    , "result": true
    },
   "size_300": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 300
    , "height": 300
    , "result": true
    },
   "size_500": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 500
    , "height": 500
    , "result": true
    }
  }
}

However, instead of using "result": true" you may also want to add a final “store” step that is using the /s3/store robot. In that case you would need to give that step a property that says "use": ["size_45", "size_300", "size"500"].

Let me know if this works for you / if you have any other questions.

--fg

thank you for help on this issue. but I tried to modify my template I got invalid json error, I got Following error.

“Sorry, but there was an error updating your template.”

{"steps": {
   "size_45": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 45
    , "height": 45
    },
   "size_300": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 300
    , "height": 300
    },
   "size_500": {
      "robot": "/image/resize"
    , "use": ":original"
    , "width": 500
    , "height": 500
    },

“store”:

{ "robot": "/s3/store"
, "bucket": "BUCKET"
, "use": ["size_45", "size_300", "size"500"]  
, "key": "REDACTED"
, "secret": "REDACTED"
}

} }

Hey, I looked at the json and I think the problem is at the value for “use” for the /s3/store robot. Please notice the ‘,“size"500”]’. This should really be ‘,“size_500”]’.

Please try that and let us know if you need further help. :slight_smile:

--tk

Closing this since the thread is inactive. Please feel free to re-open if there are still remaining problems!

Well, thank you for all of you, Now Following are some of the my queries.

  1. I want to specify the AS-3 bucket which need to store the images.
  2. I want to change the images name as per my own that need to save. (Renaming the images.)

How I can do it please respond , I did not find any relevant docs on.

  1. In the code you pasted previously, just replace “BUCKET” with the name of the bucket you want to use
  2. I’m not sure what you mean, how would you like the files to be named?