I want to read an image from disk, modify it with rmagick (scale) and display
it in an HTML IMG tag but without saving the modified image to disk.
Is there a way to send the Image object directly to the IMG tag??
Something like:
<%
require "RMagick"
include Magick
img = Image.read("image.jpg").first
## Do stuff to img.... like scale it down....
%>
<img src="<%=img.to_blob%>"></img>
regards,
Horacio
See http://redhanded.hobix.com/inspect/sparklinesForMinimalists.html
···
On 10/2/06, Horacio Sanson <horacio.sanson@gmail.com> wrote:
I want to read an image from disk, modify it with rmagick (scale) and display
it in an HTML IMG tag but without saving the modified image to disk.
Is there a way to send the Image object directly to the IMG tag??
Something like:
<%
require "RMagick"
include Magick
img = Image.read("image.jpg").first
## Do stuff to img.... like scale it down....
%>
<img src="<%=img.to_blob%>"></img>
Horacio Sanson wrote:
I want to read an image from disk, modify it with rmagick (scale) and display
it in an HTML IMG tag but without saving the modified image to disk.
Is there a way to send the Image object directly to the IMG tag??
Something like:
<%
require "RMagick"
include Magick
img = Image.read("image.jpg").first
## Do stuff to img.... like scale it down....
%>
<img src="<%=img.to_blob%>"></img>
http://www.ietf.org/rfc/rfc2397.txt
Warning. Base64, madness, and death lie that way.
Well, not really, but I don't think it works in IE.
David Vallner
See http://redhanded.hobix.com/inspect/sparklinesForMinimalists.html
I don't know what "Bumsparks" are, but they sound frightfully exciting.
Martin
Cool.... I took me 3 mins to get what I wanted....
Here is the code I used:
<%
require 'base64'
require 'RMagick'
require 'cgi'
include Magick
img = Image.read('test.jpg').first
def build_url(data)
data = Base64.encode64(data).delete("\n")
return "data:image/jpeg;base64,#{CGI.escape(data)}"
end
%>
<div>
<img src="<%=build_url(img.to_blob)%>"></img>
</div>
This displays the image in the page with no problems....
···
~
月曜日 02 10月 2006 20:33、Martin Coxall さんは書きました:
> See http://redhanded.hobix.com/inspect/sparklinesForMinimalists.html
I don't know what "Bumsparks" are, but they sound frightfully exciting.
Martin
Horacio Sanson wrote:
This displays the image in the page with no problems....
Beware that here the data is encoded within the URI, so you are limited on your browsers' maximal URI length. I've read somewhere that Opera accepts URIs of maximal length 4kb, so that may be the upper limit for the image size.
See: data URI scheme - Wikipedia
Greetings,
Esad