dynamic rails img headers
find views -name [a-z]\*rhtml | xargs -n1 grep -H "@page_title" | grep -v "<%" | sed "s/\@page_title = //" | sed "s/rhtml/png/" | sed "s:views/::" | sed "s:/:_:g" | sed "s:^:public/images/beta/headers/hdr_:" | sed "s/ //g"
11319 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
find views -name [a-z]\*rhtml | xargs -n1 grep -H "@page_title" | grep -v "<%" | sed "s/\@page_title = //" | sed "s/rhtml/png/" | sed "s:views/::" | sed "s:/:_:g" | sed "s:^:public/images/beta/headers/hdr_:" | sed "s/ //g"
#!/bin/sh for i in `ls *.jpg`; do convert -geometry 320x240 $i galleria-$i done
require 'RMagick' class PhotoController < ApplicationController [...snip...] def render_resized_image @photo=Photo.find(@params["id"]) maxw = @params["width"] != nil ? @params["width"].to_i : 90 maxh = @params["height"] != nil ? @params["height"].to_i : 90 aspectratio = maxw.to_f / maxh.to_f pic = Magick::Image.from_blob(@photo.image)[0] picw = pic.columns pich = pic.rows picratio = picw.to_f / pich.to_f if picratio > aspectratio then scaleratio = maxw.to_f / picw else scaleratio = maxh.to_f / pich end #breakpoint thumb = pic.resize(scaleratio) @response.headers["Content-type"]=@photo.mime end end
def scale_crop ....... # Open the image-file img = Image.read(picture_name).first scale_image = img.scale(scale_width,scale_height ) crop_image = scale_image.crop(left_x, left_y, right_x, right_y) @response.headers["Content-Type"] = "image/jpeg" render_text do |response| print crop.to_blob end end
tar zxvf jpegsrc.v6b.tar.gz cd jpeg-6b cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure --enable-shared --enable-static make sudo make install sudo ranlib /usr/local/lib/libjpeg.a
require 'RMagick' maxwidth = 120 maxheight = 160 aspectratio = maxwidth.to_f / maxheight.to_f imgfile = 'world' pic = Magick::Image.read(imgfile + '.jpg').first imgwidth = pic.columns imgheight = pic.rows imgratio = imgwidth.to_f / imgheight.to_f imgratio > aspectratio ? scaleratio = maxwidth.to_f / imgwidth : scaleratio = maxheight.to_f / imgheight thumb = pic.resize(scaleratio) white_bg = Magick::Image.new(maxwidth, thumb.height) pic = white_bg.composite(thumb, Magick::CenterGravity, Magick::OverCompositeOp) pic.write(imgfile + '.thumb.jpg')