Closed garyfeng closed 2 years ago
This does it
googleimagesdownload -k "swimming free style" -oc "male swimmer" -l 50 --extract_metadata --coco_metadata --type photo --size ">640*480" --format jpg --aspect_ratio_threshold 0.5 --output_directory "E:\swimpose" --image_directory "square"
and the output will contain
Deleting Image, aspect ratio 0.56 ====> 20.n2kia8vhwhbeiuyyzb0u.jpg
Deleting Image, aspect ratio 0.56 ====> 22.m1m2018c016.jpg
As the user I want to add an option to limit the download to only images that are neither too wide nor too tall. The option
--aspect_ratio_threshold
takes a float number between 0-1 as value. For example,--aspect_ratio_threshold 0.5
means that we only keep images wheremin(h,w)/max(h,w)>=0.5
, whereh,w
and the height and width of the image. In this case, a 240x500 or 800x300 image would be too wide/tall to keep, but a 250x500 image will be kept.--extract_metadata
is used.--coco_metadata
is used, the offending image will not be shown in the coco metadata output.Rational -- a downstream step will generate OOM error when the image is too narrow or too tall. The threshold happens to be
0.5
. Rather than having an extra step to filter out these images, we can add this as a download requirement.