-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image search #368
Comments
Hello! How can I assist you with image search on GitHub? |
Say I have an image, dimensions 800 pixels by 100 pixels, and a second image, dimensions 800 pixels by 2000 pixels. How can I efficiently detect if the first image matches the bottom 100 pixels of the second image? I would like to do this programmatically in a Windows *.BAT file, possibly using ImageMagick. |
To detect if the first image matches the bottom 100 pixels of the second image programmatically, you can use ImageMagick's command-line tool called Here's how you can accomplish this using a Windows
Once ImageMagick is installed, you can use the following @echo off
setlocal
set "first_image=path\to\first_image.png"
set "second_image=path\to\second_image.png"
set /a "second_image_height=2000"
set /a "comparison_height=100"
rem Crop the second image to the desired height
magick "%second_image%" -crop x%comparison_height%+0+%((%second_image_height% - %comparison_height%))% second_crop.png
rem Compare the first image with the cropped second image
magick compare -metric AE "%first_image%" second_crop.png null: 2>&1 | findstr /R /C:"^[0-9]*$" > comparison_result.txt
set /p "comparison_result=" < comparison_result.txt
rem Check if the comparison result is zero (0), indicating a match
if %comparison_result% equ 0 (
echo "The first image matches the bottom %comparison_height% pixels of the second image."
) else (
echo "The first image does not match the bottom %comparison_height% pixels of the second image."
)
rem Clean up temporary files
del second_crop.png comparison_result.txt
endlocal Make sure to replace This script loads the second image, crops it to the desired height using the formula Finally, the script cleans up temporary files, if any. I hope this helps! Let me know if you have any further questions. |
No description provided.
The text was updated successfully, but these errors were encountered: