Is it possible for Paperclip to generate a new image (without source)?

I create an image based on user input - the background will be either an image or a color, and then several other images may or may not be drawn on top.

When checking paperclip documents, it mentions that you can use ImageMagik for post-processing images and that post-processing will never work if it does not already have an image.

If I can make imagemagik scripts to fit / color / resize the image, is there a way to generate the image, or will I need to add some kind of hacker pixel to upload (and then postprocess in to the image I want)?

+6
source share
2 answers

I would try the following:

  • You have a default image in the application resource folder
  • If the model you want to save does not have an attachment, I would assign it the one mentioned above: a_model.image = File.open('...')
  • Then, after saving a_model , post processing should usually be done
+3
source

ImageMagick can generate the original image for you, consisting of a simple rectangle filled with one color. For example, this will create a 150x100 red image:

 convert -size 150x100 xc:"#ff0000" starting_image.png 
+4
source

All Articles