W.M.
Joined
800 Experience
0 Lessons Completed
1 Question Solved
Activity
Here's the SQL:
select s.name, p.name, count(i.id) as count from items i
left join products p
on p.id = i.product_id
left join stores s
on s.id = i.store_id
group by p.id, s.id
Thank you.
Thanks to Jancko-m at github, he provided the following solution:
MiniMagick::Tool::Convert.new do |cmd|
convert << "input.png"
convert.bordercolor("white")
convert.border("1"),
convert.set("option:distort:viewport", "%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]")
convert.virtual_pixel("edge")
convert.distort("SRT", "0")
convert << "output.png"
end
Basically I am asking how to do this:
convert input.png -bordercolor white -border 1 -set option:distort:viewport "%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]" -virtual-pixel edge -distort SRT 0 output.png
inside a Carrierwave
uploader class.
Note: this command makes rectangular images into squares with white background.
Thank you.