How to render a transparent gif pixel in Phoenix?

owyongsk

Coming from a Rails background I was hoping I could render a transparent pixel gif. To do this on Rails I simply

gif_data = "GIF89a\x01\x00\x01\x00\x80\xFF\x00\xC0\xC0\xC0\x00\x00\x00!\xF9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x01\x012\x00;"
respond_to do |format|
  format.gif { render text: gif_data, content_type: "image/gif" }
end

Would appreciate some cleaner way to do it than my own.

owyongsk

After some googling and learning string encodings. I converted the Hex code of the actual transparent gif

47 49 46 38 39 61 01 00 01 00 80 00 00 00 00 00 FF FF FF 21 F9 04 01 00 00 00 00 2C 00 00 00 00 01 00 01 00 00 02 01 44 00 3B

using Hexate package into this

<<71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 0, 0, 0, 0, 0, 255, 255, 255, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 68, 0, 59>>

so to use this in a Phoenix Controller I can

gif_data = <<71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 0, 0, 0, 0, 0, 255, 255, 255, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 68, 0, 59>>
conn = put_resp_content_type(conn, "image/gif")
text conn, gif_data

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to render full image slowly pixel by pixel?

How to render json with Phoenix framework?

Is there a way to render animated transparent gif on canvas and change the delay between frames

Swing: how to know if a pixel of a JComponent is transparent?

Java BufferedImage how to know if a pixel is transparent

How to convert PNG images to a transparent GIF?

How do I create a transparent gif in Go?

How to make transparent background of a gif animation?

How to render a JSON file with the Phoenix framework?

How to render raw html in Phoenix framework

phoenix framework how to render object as json in a template

How to Render Raw JavaScript Data in Phoenix Framework

How to Render a Scaled Pixel Buffer with Xlib/XRender

How to render a pixel matrix directly into a wpf element?

How to render a UIView with transparent background on an SCNPlane in ARKit?

Saving Transparent PNG as Transparent GIF

Animated gif with wxpython phoenix

How to perform per pixel collision test for transparent images?

Transparent pixel in SKMutableTexture

How to make background of an animated gif transparent using PHP?

How to display an animated gif with transparent background im MIT App Inventor?

How to determine the number of transparent pixels in an animated GIF frame?

Problem with gif with transparent background

How to render html template in javascript template in Phoenix Framework

How do I render a list of elements with Phoenix.HTML

Phoenix - controller with multiple render

three.js How to render a simple white dot/point/pixel

Dynamically Generate Transparent Tracking Pixel

Render pixel buffer with Cocoa