When installing this module for the first time, I found that my existing Imagefield Focus data were not being converted to Focal Point data.
I think there are some errors in the function “focal_point_migrate_imagefield_focus_data” in focal_point.install.
The function gets the dimensions of the original image by finding the width and height as stored in $file->metadata. On my site, $file->metadata did not exist. I solved this issue by replacing line 92 $focal_point = round(100 * $focal_point_x / $file->metadata['width']) . ',' . round(100 * $focal_point_y / $file->metadata['height']);
with the following:
$file_info = image_get_info($file->uri);
$focal_point = round(100 * $focal_point_x / $file_info['width']) . ',' . round(100 * $focal_point_y / $file_info['height']);
Also, it seems the calculations for determining the focal point are incorrect. In Imagefield Focus, it seems that the focus rectangle is not defined by a straight set of coordinates, but rather coordinates for the top left corner, and then two values for the X and Y offset for the bottom right corner. So to get my focal points to convert correctly, I had to replace lines 90 and 91
$focal_point_x = $x1 + round(($x2 - $x1) / 2);
$focal_point_y = $y1 + round(($y2 - $y1) / 2);
with the following:
$focal_point_x = $x1 + round($x2 / 2);
$focal_point_y = $y1 + round($y2 / 2);
Comment | File | Size | Author |
---|---|---|---|
#2 | does_not_convert-2661230-2.patch | 915 bytes | bleen |
Comments
Comment #2
bleen CreditAttribution: bleen commentedComment #3
bleen CreditAttribution: bleen commentedThis was a good catch so I went ahead and committed it.
Comment #5
valsgalore CreditAttribution: valsgalore commentedThanks for the quick response! The beta6 release works great!