Skip to content

Commit

Permalink
[Frameit] apply rounded corners before framing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Tho虉ni committed Jan 17, 2024
1 parent e19e01b commit 0b6b438
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions frameit/lib/frameit/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ def put_into_frame
end
end

# Apply rounded corners for all iPhone 14 devices
if screenshot.device.id.to_s.include?("iphone-14") || screenshot.device.id.to_s.include?("iphone14")

maskData = MiniMagick::Tool::Convert.new do |img|
img.size("#{screenshot.size[0]}x#{screenshot.size[1]}")
img.canvas('none')
img.draw("roundrectangle 0,0,#{screenshot.size[0]},#{screenshot.size[1]},100,100")
img << 'png:-'
end

# Create a mask
mask = MiniMagick::Image.read(maskData)

@image = @image.composite(mask, "png") do |c|
c.channel("A")
c.compose("DstIn")
c.alpha("on")
end
end

@image = frame.composite(image, "png") do |c|
c.compose("DstOver")
c.geometry(offset['offset'])
Expand Down

0 comments on commit 0b6b438

Please sign in to comment.