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);
CommentFileSizeAuthor
#2 does_not_convert-2661230-2.patch915 bytesbleen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valsgalore created an issue. See original summary.

bleen’s picture

Status: Active » Needs review
FileSize
915 bytes
bleen’s picture

Status: Needs review » Fixed

This was a good catch so I went ahead and committed it.

  • bleen committed d63fced on authored by valsgalore
    Issue #2661230 by bleen, valsgalore: Does not convert existing...
valsgalore’s picture

Thanks for the quick response! The beta6 release works great!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.