|  |  | @ -46,11 +46,14 @@ module Submissions | 
			
		
	
		
		
			
				
					
					|  |  |  |           when 'image', 'signature' |  |  |  |           when 'image', 'signature' | 
			
		
	
		
		
			
				
					
					|  |  |  |             attachment = submitter.attachments.find { |a| a.uuid == value } |  |  |  |             attachment = submitter.attachments.find { |a| a.uuid == value } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             io = StringIO.new(download_supported_image_data(attachment)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             scale = [(area['w'] * width) / attachment.metadata['width'], |  |  |  |             scale = [(area['w'] * width) / attachment.metadata['width'], | 
			
		
	
		
		
			
				
					
					|  |  |  |                      (area['h'] * height) / attachment.metadata['height']].min |  |  |  |                      (area['h'] * height) / attachment.metadata['height']].min | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             image = Vips::Image.new_from_buffer(attachment.download, '') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             image = image.autorot.resize([scale * 4, 1].min) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             io = StringIO.new(image.write_to_buffer('.png')) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             canvas.image( |  |  |  |             canvas.image( | 
			
		
	
		
		
			
				
					
					|  |  |  |               io, |  |  |  |               io, | 
			
		
	
		
		
			
				
					
					|  |  |  |               at: [ |  |  |  |               at: [ | 
			
		
	
	
		
		
			
				
					|  |  | @ -244,7 +247,7 @@ module Submissions | 
			
		
	
		
		
			
				
					
					|  |  |  |       page.box.height = attachment.metadata['height'] * scale |  |  |  |       page.box.height = attachment.metadata['height'] * scale | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       page.canvas.image( |  |  |  |       page.canvas.image( | 
			
		
	
		
		
			
				
					
					|  |  |  |         StringIO.new(download_supported_image_data(attachment)), |  |  |  |         StringIO.new(attachment.preview_images.first.download), | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         at: [0, 0], |  |  |  |         at: [0, 0], | 
			
		
	
		
		
			
				
					
					|  |  |  |         width: page.box.width, |  |  |  |         width: page.box.width, | 
			
		
	
		
		
			
				
					
					|  |  |  |         height: page.box.height |  |  |  |         height: page.box.height | 
			
		
	
	
		
		
			
				
					|  |  | @ -253,15 +256,6 @@ module Submissions | 
			
		
	
		
		
			
				
					
					|  |  |  |       pdf |  |  |  |       pdf | 
			
		
	
		
		
			
				
					
					|  |  |  |     end |  |  |  |     end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     def download_supported_image_data(attachment) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       if SUPPORTED_IMAGE_TYPES.include?(attachment.content_type) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         attachment.download |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       else |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Vips::Image.new_from_buffer(attachment.download, '') |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                    .write_to_buffer('.png') |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def h |  |  |  |     def h | 
			
		
	
		
		
			
				
					
					|  |  |  |       Rails.application.routes.url_helpers |  |  |  |       Rails.application.routes.url_helpers | 
			
		
	
		
		
			
				
					
					|  |  |  |     end |  |  |  |     end | 
			
		
	
	
		
		
			
				
					|  |  | 
 |