Package: optimaimg
OptimaImgOptimaImg is an image processing toolkit that leverages the performance of Rust with the ease of Python.Table of ContentsOptimaImgTable of ContentsFeaturesInstallationImportant NoteUsageConvert an Image to GrayscaleResize an ImageRotate an ImageApply BlurApply SharpenApply Edge DetectionApply Sepia FilterAdjust SaturationAdjust BrightnessAdjust ContrastAdjust HueBatch Resize ImagesConvert Image Color SpaceOverlay imagesCLI Usage ExamplesBenchmark ResultsContributingLicenseFeaturesHigh-performance image operations written in Rust.Easy-to-use Python interface.Cross-platform support and optimization.Convert images to grayscale.Resize images to specified dimensions.Rotate images by a specific rotation angle in degrees.Apply Gaussian blur to images.Sharpen images to enhance edges.Detect edges within images using the Sobel operator.Apply a sepia tone filter to images for a vintage effect.Adjust the saturation of images to enhance or mute colors.Convert image color space.InstallationTo install OptimaImg, simply run the following command:pipinstalloptimaimgAlternatively, if you have cloned the repository and want to install it directly from the source code, you can run:poetryinstallImportant NoteOptimaImg has not been tested on Windows OS and may not perform as expected on that platform.UsageAfter installing the package, you can use it to perform various image processing tasks:Convert an Image to GrayscaleTo convert an image to grayscale, you can use theconvert_to_grayscalefunction:fromoptimaimgimportconvert_to_grayscaleinput_path='path/to/your/image.jpg'output_path='path/to/save/grayscale_image.png'# Convert the image to grayscale and save itconvert_to_grayscale(input_path,output_path)Resize an ImageTo resize an image to specific dimensions, use theresize_imagefunction:fromoptimaimgimportresize_imageinput_path='path/to/your/image.jpg'output_path='path/to/save/resized_image.png'width=100# desired widthheight=100# desired height# Resize the image and save itresize_image(input_path,output_path,width,height)Rotate an ImageTo rotate an image by a specific rotation angle in degrees, use therotate_imagefunction:fromoptimaimgimportrotate_imageinput_path='path/to/your/image.jpg'output_path='path/to/save/rotated_image.png'degree=45# desired degree# Rotate the image and save itrotate_image(input_path,output_path,degree)Apply BlurTo apply a Gaussian blur to an image:fromoptimaimgimportapply_blur# Apply a blur with a sigma value of 2.0apply_blur(input_path,output_path,sigma=2.0)Apply SharpenTo sharpen an image:fromoptimaimgimportapply_sharpen# Sharpen the imageapply_sharpen(input_path,output_path)Apply Edge DetectionTo apply edge detection to an image:fromoptimaimgimportapply_edge_detection# Detect edges in the imageapply_edge_detection(input_path,output_path)Apply Sepia FilterTo apply a sepia tone filter to an image:fromoptimaimgimportapply_sepia# Apply a sepia tone filterapply_sepia(input_path,output_path)Adjust SaturationTo adjust the saturation of an image, thereby enhancing or muting its colors, use theadjust_saturationfunction:fromoptimaimgimportadjust_saturationinput_path='path/to/your/image.jpg'output_path='path/to/save/saturation_adjusted_image.png'factor=1.5# factor > 1 increases saturation, factor < 1 decreases saturation# Adjust the saturation of the image and save itadjust_saturation(input_path,output_path,factor)Adjust BrightnessTo adjust the brightness of an image:fromoptimaimgimportadjust_brightnessinput_path='path/to/your/image.jpg'output_path='path/to/save/brightness_adjusted_image.png'brightness=1.2# value > 1 increases brightness, value < 1 decreases brightness# Adjust the brightness of the image and save itadjust_brightness(input_path,output_path,brightness)Adjust ContrastTo adjust the contrast of an image:fromoptimaimgimportadjust_contrastinput_path='path/to/your/image.jpg'output_path='path/to/save/contrast_adjusted_image.png'contrast=1.2# value > 1 increases contrast, value < 1 decreases contrast# Adjust the contrast of the image and save itadjust_contrast(input_path,output_path,contrast)Adjust HueTo adjust the contrast of an image:fromoptimaimgimportadjust_contrastinput_path='path/to/your/image.jpg'output_path='path/to/save/contrast_adjusted_image.png'hue=1.2# value > 1 increases contrast, value < 1 decreases contrast# Adjust the hue of the image and save itadjust_hue(input_path,output_path,hue)Batch Resize ImagesBatch resize images to the specified dimensions:fromoptimaimgimportbatch_resize_imagesinput_images_path=["path/to/image1","path/to/image2"]output_path='path/to/save/images/'width=20height=20batch_resize_images(input_images_path,output_path,width,height)Convert Image Color SpaceConvert images between different color spaces such as HSV or RGB.fromoptimaimgimportconvert_color_spaceinput_path='path/to/your/image.jpg'output_path='path/to/save/converted_image.jpg'# Convert the image color space from RGB to HSVconvert_color_space(input_path,output_path,'rgb','hsv')Overlay imagesOverlay an image onto anotherfromoptimaimgimportoverlay_imagesinput_path='path/to/your/image.jpg'overlay_path='path/to/your/overlay-image.jpgoutput_path='path/to/save/converted_image.jpg'x=100# The x-coordinate of the overlay position on the base image.y=100# The y-coordinate of the overlay position on the base image.alpha=0.2# The transparency of the overlay (0.0 to 1.0).overlay_images(inputh_path,overlay_path,output_path,x,y,alpha)CLI Usage ExamplesConvert an Image to Grayscaleoptimaimg-cligrayscalepath/to/input.jpgpath/to/output.jpgResize an Imageoptimaimg-cliresizepath/to/input.jpgpath/to/output.jpg200200Options:usage:optimaimg-cli[-h]resize,grayscale,rotate,blur,sharpen,edge_detection,sepia,brightness,contrast,saturation,hue,batch_resize,convert_color_space,overlay...

optimaimgCLI

positionalarguments:resize,grayscale,rotate,blur,sharpen,edge_detection,sepia,brightness,contrast,saturation,hue,batch_resize,convert_color_space,overlayresizeResizeanimagegrayscaleConvertanimagetograyscalerotateRotateanimageblurApplyblurtoanimagesharpenSharpenanimageedge_detectionApplyedgedetectiontoanimagesepiaApplysepiatonetoanimagebrightnessAdjustthebrightnessofanimagecontrastAdjustthecontrastofanimagesaturationAdjustthesaturationofanimagehueAdjustthehueofanimagebatch_resizeBatchresizeimagesconvert_color_spaceConvertimagecolorspaceoverlayOverlayanimageontoanother

options:-h,--helpshowthishelpmessageandexitBenchmark ResultsFunctionGrayscaleBlurRotateOptimaImg0.02070.057710.03338OpenCV0.040810.067360.07511Pillow0.172590.665450.45785These benchmark results demonstrate that OptimaImg outperforms both OpenCV and Pillow, with a notably higher speed advantage over Pillow.Please note that the actual performance can vary based on the system and the specific images processed.ContributingContributions are welcome! Please seeCONTRIBUTING.mdfor details on how to contribute to the OptimaImg project.LicenseOptimaImg is distributed under the MIT license. SeeLICENSEfor more information.