🚧 chop-edges: Chop edges of given image
This commit is contained in:
		
							parent
							
								
									728a265aa7
								
							
						
					
					
						commit
						04d109f904
					
				
					 1 changed files with 31 additions and 0 deletions
				
			
		
							
								
								
									
										31
									
								
								chop-edges
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								chop-edges
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| #!/usr/bin/python3 | ||||
| import click | ||||
| import subprocess | ||||
| from pathlib import Path | ||||
| 
 | ||||
| 
 | ||||
| @click.command | ||||
| @click.option("--top", default=0) | ||||
| @click.option("--bottom", default=0) | ||||
| @click.option("--left", default=0) | ||||
| @click.option("--right", default=0) | ||||
| @click.argument("image", type=click.Path(exists=True, dir_okay=False, path_type=Path), required=True) | ||||
| def chop(top, bottom, left, right, image): | ||||
|     """ | ||||
|     Chop edges of the given image. | ||||
| 
 | ||||
|     Meant to be used with an auto-reloading image viewer on the output image. | ||||
|     """ | ||||
|     image_out = image.stem + ".out" + image.suffix | ||||
|     print(image_out) | ||||
|     subprocess.run([ | ||||
|       "convert", | ||||
|       image, | ||||
|       "-gravity", "North", "-chop", f"0x{top}", | ||||
|       "-gravity", "South", "-chop", f"0x{bottom}", | ||||
|       "-gravity", "West",  "-chop", f"{left}x0", | ||||
|       "-gravity", "East",  "-chop", f"{right}x0", | ||||
|       image_out], check=True) | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     chop() | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue