{"id":18893212,"url":"https://github.com/hansalemaos/getpartofimg","last_synced_at":"2026-05-15T12:32:32.943Z","repository":{"id":181826883,"uuid":"667481492","full_name":"hansalemaos/getpartofimg","owner":"hansalemaos","description":"Extracts a part of the image specified by width and height from the given image file path using OpenCV.","archived":false,"fork":false,"pushed_at":"2023-07-17T15:46:47.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-19T12:56:30.050Z","etag":null,"topics":["crop","image","opencv","part"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/getpartofimg/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-17T15:46:26.000Z","updated_at":"2023-07-17T16:38:23.000Z","dependencies_parsed_at":"2023-07-17T16:59:58.640Z","dependency_job_id":null,"html_url":"https://github.com/hansalemaos/getpartofimg","commit_stats":null,"previous_names":["hansalemaos/getpartofimg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fgetpartofimg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fgetpartofimg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fgetpartofimg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fgetpartofimg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/getpartofimg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239869221,"owners_count":19710485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crop","image","opencv","part"],"created_at":"2024-11-08T08:12:28.650Z","updated_at":"2026-05-15T12:32:27.921Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Extracts a part of the image specified by width and height from the given image file path using OpenCV.\r\n\r\n## pip install getpartofimg \r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\nParameters:\r\n-----------\r\nimage : Any\r\n\tThe file path of the image from which a part will be extracted.\r\n\r\nwidth : int\r\n\tThe desired width of the extracted part.\r\n\r\nheight : int\r\n\tThe desired height of the extracted part.\r\n\r\nallow_resize : bool, optional (default=True)\r\n\tIf True, allows resizing of the input image when the specified width or height is greater\r\n\tthan the original image's dimensions.\r\n\r\nReturns:\r\n--------\r\nnumpy.ndarray\r\n\tThe extracted part of the image as a NumPy array.\r\n\r\nRaises:\r\n-------\r\nValueError\r\n\tIf the 'allow_resize' parameter is set to False and the specified width or height is greater than\r\n\tthe original image's dimensions, a ValueError is raised with a message indicating that the image is too small.\r\n\r\nNotes:\r\n------\r\nThe function uses the 'cv2.imread_plus' function ( https://github.com/hansalemaos/a_cv_imwrite_imread_plus )\r\nto read the image from the given file path. It then calculates\r\nthe possible ranges for extracting the desired part based on the image's dimensions and the specified width\r\nand height. If the 'allow_resize' parameter is True, the function resizes the image using 'cv2.easy_resize_image'\r\n( https://github.com/hansalemaos/a_cv2_easy_resize )\r\nwith the 'cv2.INTER_AREA' interpolation method to fit the desired part. Otherwise, it raises a ValueError.\r\n\r\nRandom starting coordinates within the allowable range are generated to extract the part of the image specified\r\nby the given width and height.\r\n\r\n\r\n\r\n```python\r\n# Example usage:\r\nimport cv2\r\nfrom getpartofimg import get_part_of_image\r\nim = get_part_of_image(image=r\"https://raw.githubusercontent.com/hansalemaos/screenshots/main/pic5.png\", width=600, height=500, allow_resize=True)\r\ncv2.imwrite('c:\\\\testimage.png', im)\r\n\r\n\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fgetpartofimg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Fgetpartofimg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fgetpartofimg/lists"}