While trying to improve PerceptualHash performance, I came across a couple errors. With very large images, PerceptualHash takes forever to compute. I'm submitting the errors as separate issues with the same code sample.
Resize(Percent), as seen below, doesn't change the size of the image.
Doesn't resize no matter what image I use, but here's a link to one I've tested this on - http://www.nasa.gov/images/content/378535main_lands.jpg
```
public static ImageMagick.PerceptualHash PHash(this FileInfo file, int imageSizeConstraint = 5000)
{
if (imageSizeConstraint < 1000)
imageSizeConstraint = 1000;
using (MagickImage image = new MagickImage(file.FullName))
{
if (image.Width > imageSizeConstraint || image.Height > imageSizeConstraint)
{
double percent = imageSizeConstraint / (double)Math.Max(image.Width, image.Height);
Percentage p = new Percentage(percent);
image.Resize(p);
}
return image.PerceptualHash();
}
}
```
I'm initially calling this method with file.PHash(1000) in a loop that increases size by 1000 up to max image size to test for a sweet spot on PerceptualHash computation time.
Resize(Percent), as seen below, doesn't change the size of the image.
Doesn't resize no matter what image I use, but here's a link to one I've tested this on - http://www.nasa.gov/images/content/378535main_lands.jpg
```
public static ImageMagick.PerceptualHash PHash(this FileInfo file, int imageSizeConstraint = 5000)
{
if (imageSizeConstraint < 1000)
imageSizeConstraint = 1000;
using (MagickImage image = new MagickImage(file.FullName))
{
if (image.Width > imageSizeConstraint || image.Height > imageSizeConstraint)
{
double percent = imageSizeConstraint / (double)Math.Max(image.Width, image.Height);
Percentage p = new Percentage(percent);
image.Resize(p);
}
return image.PerceptualHash();
}
}
```
I'm initially calling this method with file.PHash(1000) in a loop that increases size by 1000 up to max image size to test for a sweet spot on PerceptualHash computation time.