Rendering a Rails partial to an image - ruby-on-rails

So, I have a problem and my initial question is: Is this possible?
I'm allowing people to customize the appearance of something using css, and then once they save it I want to turn it into thumbnails to use to display it in various other places (in other sizes maintaining that same aspect ratio).
So the question is, is it possible to do something where I render that partial, then it's saved to an image that I can upload to aws in various sizes etc. using paperclip? Once I get the image I can do the paperclip part, but it's getting that partial to render the html/css and save that to an image... Thoughts?
Just know, any help and/or thoughts at all would be great!
Thanks,
Mike

This might help you:
rails convert html to image

Related

Generate PDF with images Prawn PDF Rails

I have a rails app using Prawn to generate a PDF and I need to set the PDF to a vertical orientation with an 8.5 x 11 png image on each page (there will be 3).
What would be the best way to make sure these images fit the constraints of the PDF? I beleive I can use a bounding box to control the position but I'm having a hard time wrapping my mind around the code behind it. I'll keep pouring over the docs but if anyone has a suggestion on to get 3 8.5x11 images to display on each page that'd be great.
I was able to figure this out by calling arguments in a hash inside of the initialize method for my pdf
def initialize
super(:page_size=> "A4",:top_margin => 80,:bottom_margin => 40,:template => 'public/template.pdf')
#your pdf code goes here
end

Best and easiest way to directly render CGPDFPage

I am looking for an easy, direct and straightforward way to render a CGPDFPage and view it on an iOS device.
The rendered page should fill the view to which it is drawn and be crispy clear.
The less the code used in the method the better. However, if the amount of code required for the best result is too much, then it is preferred that the code be organised and well written.
Please do include a way to view in RGB color instead of CMYK.
I'd really appreciate it if you didn't suggest PDF readers/viewers or Github projects since I prefer not using them.
Thanks in advance.
I don't think this is a valid question. Anyways you should take a look to apple sample codes first.
Here you go
https://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010281

Solution for display image in library website

In my website, I have a library contain all image of user, I want to display all image in this library. How can I do it?
I have solution but I can’t do it. This’s my solution. I’ll create thumbnail for each image and display it in library. Size of thumbnail is very small, so I don’t worry about performance. If I create thumbnail in my server. It must download, read and resize these images, then it return for my website. This way I feel not good. I have many images, each customer have about hundreds images, size of each image about 1mb or 2mb. I think have no server can handle it. Another way is create thumbnail on client by jQuery, but I can’t do it and my friend talk with me. jQuery don’t handle it. How can I do it for my solution? Hope you understand what I mean
I think you can use pagination if you would like to return million images in a page
so for instance 50 images per page to keep up with your web performance
You need to generate thumbnails on server and show thumbnails in the gallery. When a user clicks on a thumbnail in the gallery, show the full image.
I think your first idea is better. Because you don't want to show the images in actual size and you want to make them smaller. So using their thumbnail is a good solution. If you think this could add some complexity you can make the thumbnails for each image when user uploads them and in your view just use the thumbnails.

Screen Capture / Saving CSS3 to image somehow?

I have a div that's 512x512 and the user can drag/drop stuff around.
I would like to save this for use in an email which doesn't support many CSS properties.
My initial idea was to take a screenshot and crop it but I can't seem to find a good way of doing this.
I figured out how to do this and wrote a blog post on it here - http://jbeas.com/ruby-on-rails/rails-screenshot-pdf-gem/

How can a webserver do images like this?

Below is a thumbnail type image that is on a post from http://doctype.com/, if you haven't been on the site yet, it is similar to this site but for css/design stuff and when you post a question you can have it post a screenshot image as well for you of a website url.
Below is one of them I saw, do you think this is something done programmticly?
IF so how would you do this server side?
(source: doctype.com)
You can achieve this screenshot-in-a-note effect by having a template image of the curled-paperclipped-note (the curled border, the paper clip, the shadow) and a mask for where the screenshot of the site should fit inside the template. Once you get the screenshot you just rotate it slightly and compose it with the template.
To compose it programmatically you could use ImageMagick as sugested by cpharmston.
Here's an alternative of how to compose the two images with PIL and python.
If it is done programmatically, it likely uses an image processing library. GD and ImageMagick are two of the more popular ones.
Yes, you need to do it programmatically on the server. There are some flash plugins to do it, but I think server side is the way to go.
This is how I did it:
http://www.guangmingsoft.net/htmlsnapshot/html2image.htm
http://www.imagemagick.org/script/index.php

Resources