setFillColor("rgb(".$RGB['R'].",".$RGB['G'].",".$RGB['B'].")"); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_CENTER); $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_width = $tmp_metrics['textWidth']; $VAR_height = $tmp_metrics['textHeight']; $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); if($VAR_align == "center"){ $left_offset = $VAR_PL + ($core_width - $VAR_width - $VAR_PL - $VAR_PR) / 2; }elseif($VAR_align == "right"){ $left_offset = $core_width - $VAR_PR - $VAR_width; } else { $left_offset = $VAR_PL; } $tmp_txt_Canvas->annotateImage($draw, 0, 0, 0, $VAR_txt); return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $left_offset, '_y' => $VAR_PT); } //with Text Fit function FUNC_text_fit($layer) { global $PATH_components, $core_width, $core_height, $txt_join_arr; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, not needed if using Font Sizeas reference for adjustment $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_PT = isset($layer['top']) ? $layer['top'] - $VAR_font_ARR['minus_y'] : 0 - $VAR_font_ARR['minus_y']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; /* $VAR_size = isset($layer['size']) ? $layer['size'] - $VAR_font_ARR['minus_size'] : (12 - $VAR_font_ARR['minus_size']); if(isset($layer['minus_font_size'])) $VAR_size = $VAR_size - $layer['minus_font_size']; $VAR_size = $VAR_size + 8; */ $VAR_align = $layer['align']; $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; if(isset($layer['join'])) { if(isset($layer['joinreverse'])) { $join_arr = array_reverse($txt_join_arr); } else { $join_arr = $txt_join_arr; } $arrlength=count($join_arr); for($i=0;$i<$arrlength;$i++) { if($join_arr[$i] != "") $VAR_txt .= $join_arr[$i]." "; } //$VAR_txt = $txt_join; } else { //$VAR_txt = $layer['txt']; $VAR_txt = isset($layer['default']) ? $layer['default'] : $layer['txt']; } //$VAR_txt = isset($layer['txt']) ? $layer['txt'] : $layer['default']; //$VAR_txt = $layer['txt']; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor("rgb(".$RGB['R'].",".$RGB['G'].",".$RGB['B'].")"); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_CENTER); /* $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_width = $tmp_metrics['textWidth']; $VAR_height = $tmp_metrics['textHeight']; */ // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_height)/2; } else { $VAR_width = $tmp_metrics['textWidth']; $VAR_height = $tmp_metrics['textHeight']; } $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); if($VAR_align == "center"){ $left_offset = $VAR_PL + ($core_width - $VAR_width - $VAR_PL - $VAR_PR) / 2; }elseif($VAR_align == "right"){ $left_offset = $core_width - $VAR_PR - $VAR_width; } else { $left_offset = $VAR_PL; } $tmp_txt_Canvas->annotateImage($draw, 0, 0, 0, $VAR_txt); return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $left_offset, '_y' => $VAR_PT); } // Imagick Arc Functions function FUNC_text_Arc($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, not needed if using Font Sizeas reference for adjustment $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 1; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation(10 + $sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas $draw->annotation(10, 0, $VAR_txt); $VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Use font height as reference height $VAR_height = $tmp_metrics['textHeight']; $VAR_delta = $VAR_args[0] * (0.017) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); $tmp_txt_Canvas->resizeImage($VAR_width, ($VAR_height * $VAR_yscale), imagick::FILTER_UNDEFINED, 1); if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Inside Engraving Text function FUNC_text_Arc_i($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = 0; $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_2($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Inside Engraving Text function FUNC_text_Arc_2i($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = "black"; // always use black for now //$shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($text_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_top_text_1($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; $VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); // Shadow $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), -$i + 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_text_1_new($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; $VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); // Shadow $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), -$i + 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_text_1_new_d($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; $VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); // Shadow $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), -$i + 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_diamond = false; if(isset($layer['star_diamond'])) { $go_diamond = true; $f_tmp = pathinfo($layer['star_diamond']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_star_diamond = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_star_diamond = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_star_diamond = new Imagick($img_star_diamond); } $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); // Clear star diamond if($go_diamond) { if((strlen($VAR_txt_2) - 2) == 0) { // Merge Diamond stone to star $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 3.5), $VAR_star_y + ($VAR_star_size * 5)); }elseif((strlen($VAR_txt_1) - 2) == 0) { // Merge Diamond stone to star $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 4.5), $VAR_star_y + ($VAR_star_size * 5)); }else{ // Merge Diamond stone to star $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, - ($VAR_star_size * 4.4), $VAR_star_y + ($VAR_star_size * 5)); $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $VAR_txt_width - ($VAR_star_size * 4.8), $VAR_star_y + ($VAR_star_size * 5)); $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $tmp_metrics['U']['textWidth'], $VAR_star_y + ($VAR_star_size * 5)); } $tmp_star_diamond->clear(); } } $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_side_text($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_side = isset($layer['view_side']) ? $layer['view_side'] : 'L'; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; $VAR_degree = isset($layer['degree']) ? $layer['degree'] : 0; $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; $VAR_args = explode("-", $VAR_args); //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_star_w = 0; if($VAR_side == 'L') { $VAR_txt_1 = " ".substr($VAR_txt_1, 0, strlen($VAR_txt_1)/2)." "; $VAR_txt_2 = " ".substr($VAR_txt_2, 0, strlen($VAR_txt_2)/2)." "; } else { $VAR_txt_1 = " ".substr($VAR_txt_1, strlen($VAR_txt_1)/2, strlen($VAR_txt_1))." "; $VAR_txt_2 = " ".substr($VAR_txt_2, strlen($VAR_txt_2)/2, strlen($VAR_txt_2))." "; } //$VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 2; $draw->setTextKerning($VAR_kern/3); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); if($VAR_side == 'L') { $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth'] - $i + 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth']+ 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3) + $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3)+ $i, -3, $VAR_txt_2); $VAR_star_w = $tmp_metrics['U']['textWidth']; }else{ for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding - $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -3, $VAR_txt_2); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) + $i - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $VAR_star_w = $tmp_metrics['D']['textWidth']; } $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_star_w - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } $tmp_txt_Canvas->resizeImage($VAR_width * $VAR_xscale, ($VAR_txt_height * $VAR_yscale), imagick::FILTER_UNDEFINED, 1); $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_height, 0, $VAR_txt_height, $VAR_width, 0, $VAR_width - $VAR_perspective, 0, $VAR_width, $VAR_txt_height, $VAR_width, $VAR_txt_height); if($VAR_perspective > 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); $VAR_PL = -(($VAR_width / 2) - ($VAR_width / 2)) + $VAR_PL; return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_side_text_new($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_side = isset($layer['view_side']) ? $layer['view_side'] : 'L'; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; $VAR_degree = isset($layer['degree']) ? $layer['degree'] : 0; $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; $VAR_args = explode("-", $VAR_args); //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_star_w = 0; if($VAR_side == 'L') { $VAR_txt_1 = " ".substr($VAR_txt_1, 0, strlen($VAR_txt_1)/2)." "; $VAR_txt_2 = " ".substr($VAR_txt_2, 0, strlen($VAR_txt_2)/2)." "; } else { $VAR_txt_1 = " ".substr($VAR_txt_1, strlen($VAR_txt_1)/2, strlen($VAR_txt_1))." "; $VAR_txt_2 = " ".substr($VAR_txt_2, strlen($VAR_txt_2)/2, strlen($VAR_txt_2))." "; } //$VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 2; $draw->setTextKerning($VAR_kern/3); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); if($VAR_side == 'L') { $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth'] - $i + 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth']+ 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3) + $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3)+ $i, -3, $VAR_txt_2); $VAR_star_w = $tmp_metrics['U']['textWidth']; }else{ for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding - $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -3, $VAR_txt_2); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) + $i - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $VAR_star_w = $tmp_metrics['D']['textWidth']; } $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_star_w - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } $tmp_txt_Canvas->resizeImage($VAR_width * $VAR_xscale, ($VAR_txt_height * $VAR_yscale), imagick::FILTER_UNDEFINED, 1); $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_height, 0, $VAR_txt_height, $VAR_width, 0, $VAR_width - $VAR_perspective, 0, $VAR_width, $VAR_txt_height, $VAR_width, $VAR_txt_height); if($VAR_perspective > 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); $VAR_PL = -(($VAR_width / 2) - ($VAR_width / 2)) + $VAR_PL; return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_side_text_new_d($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_side = isset($layer['view_side']) ? $layer['view_side'] : 'L'; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; $VAR_degree = isset($layer['degree']) ? $layer['degree'] : 0; $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; $VAR_args = explode("-", $VAR_args); //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_star_w = 0; if($VAR_side == 'L') { $VAR_txt_1 = " ".substr($VAR_txt_1, 0, strlen($VAR_txt_1)/2)." "; $VAR_txt_2 = " ".substr($VAR_txt_2, 0, strlen($VAR_txt_2)/2)." "; } else { $VAR_txt_1 = " ".substr($VAR_txt_1, strlen($VAR_txt_1)/2, strlen($VAR_txt_1))." "; $VAR_txt_2 = " ".substr($VAR_txt_2, strlen($VAR_txt_2)/2, strlen($VAR_txt_2))." "; } //$VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 2; $draw->setTextKerning($VAR_kern/3); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); if($VAR_side == 'L') { $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth'] - $i + 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$VAR_side_padding - $tmp_metrics['U']['textWidth']+ 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3) + $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3)+ $i, -3, $VAR_txt_2); $VAR_star_w = $tmp_metrics['U']['textWidth']; }else{ for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding - $i, -3, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -3, $VAR_txt_2); $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) + $i - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['U']['textWidth'] - $tmp_metrics['D']['textWidth'] - 1 - ($VAR_side_padding * 3) - 4, 0 - $tmp_metrics['U']['textHeight'], $VAR_txt_1); $VAR_star_w = $tmp_metrics['D']['textWidth']; } $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_diamond = false; if(isset($layer['star_diamond'])) { $go_diamond = true; $f_tmp = pathinfo($layer['star_diamond']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_star_diamond = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_star_diamond = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_star_diamond = new Imagick($img_star_diamond); } $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_star_w - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); // Clear star diamond if($go_diamond) { if((strlen($VAR_txt_2) - 2) == 0) { // Merge Diamond stone to star //$tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y + ($VAR_star_size * 5)); }elseif((strlen($VAR_txt_1) - 2) == 0) { // Merge Diamond stone to star //$tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y + ($VAR_star_size * 5)); }else{ // Merge Diamond stone to star $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, - ($VAR_star_size * 8.4), $VAR_star_y + ($VAR_star_size * 5)); $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y + ($VAR_star_size * 5)); $tmp_txt_Canvas->compositeImage($tmp_star_diamond, Imagick::COMPOSITE_DEFAULT, $VAR_star_w + ($VAR_star_size), $VAR_star_y + ($VAR_star_size * 5)); } $tmp_star_diamond->clear(); } } $tmp_txt_Canvas->resizeImage($VAR_width * $VAR_xscale, ($VAR_txt_height * $VAR_yscale), imagick::FILTER_UNDEFINED, 1); $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_height, 0, $VAR_txt_height, $VAR_width, 0, $VAR_width - $VAR_perspective, 0, $VAR_width, $VAR_txt_height, $VAR_width, $VAR_txt_height); if($VAR_perspective > 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); $VAR_PL = -(($VAR_width / 2) - ($VAR_width / 2)) + $VAR_PL; return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_star_points($_X, $_Y, $_size) { return array('star' => array(array('x' => (0 + $_X), 'y' => (6.25 * $_size + $_Y)), array('x'=> (16.66 * $_size + $_X),'y'=> (6.25 * $_size) + $_Y), array('x' => (3.3 * $_size) + $_X, 'y' => (16.66 * $_size) + $_Y), array('x'=> (8.33 * $_size) + $_X,'y'=> (0 + $_Y)), array('x' => (14.16 * $_size) + $_X, 'y' => (16.66 * $_size) + $_Y), array('x'=> (0 + $_X),'y' => (6.25 * $_size) + $_Y)), 'penta' => array(array('x' => (10.52 * $_size) + $_X, 'y' => (6.25 * $_size + $_Y)), array('x'=> (11.84 * $_size) + $_X,'y' => (10.01 * $_size) + $_Y), array('x' => (8.6 * $_size) + $_X, 'y' => (12.57 * $_size) + $_Y), array('x'=> (5.25 * $_size) + $_X,'y'=>(10.1 * $_size) + $_Y), array('x' => (6.43 * $_size) + $_X, 'y' => (6.25 * $_size) + $_Y))); } function FUNC_starator($drw, $_X, $_Y, $_size, $depth, $col, $em_col) { $drw->setFillColor($em_col); if(isset($depth)) { for ($i = 1; $i <= $depth; $i++) { $tmp_arr = FUNC_star_points($_X, $_Y + $i, $_size); $drw->polygon($tmp_arr['star']); $drw->polygon($tmp_arr['penta']); } } $tmp_arr = FUNC_star_points($_X, $_Y, $_size); $drw->setFillColor($col); $drw->polygon($tmp_arr['star']); $drw->polygon($tmp_arr['penta']); } Function FUNC_vert_arc_text($layer) { global $PATH_components, $core_width, $core_height; //Parameters passed from attributes of Layer XML //Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, not needed if using Font Sizeas reference for adjustment $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : "2012"; //$VAR_txt ="2\n0\n1\n2"; $image = new Imagick(); $draw = new ImagickDraw(); $color = new ImagickPixel('#f2f4f3'); $background = new ImagickPixel('none'); // Transparent /* Font properties */ $draw->setFont('Arial'); $draw->setFontSize(50); //$draw->setFillColor($color); $draw->setFillColor('black'); //$draw->setStrokeAntialias(true); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_CENTER); //$draw->rotate(90); /* Get font metrics */ $metrics = $image->queryFontMetrics($draw, $VAR_txt); /* Create text */ //$draw->annotation(0, $metrics['ascender'], $text); $draw->annotation(0, 10, $VAR_txt); /* Create image */ //$image->newImage(300, 300, $background); $image->newImage(300, 300, new ImagickPixel('none')); //$image->setImageFormat('png'); $image->drawImage($draw); /* Output the image with headers */ //header('Content-type: image/png'); return array('txt_canvas' => $image) ; } function FUNC_text_Arc_3($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $textlength= strlen($VAR_txt); $h=0; for($i=0;$i< $textlength ;$i++) { $draw->annotation(0, $h, substr($VAR_txt,$i,1)); $h+=$tmp_metrics['ascender']*0.9; } $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_4($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $textlength= strlen($VAR_txt); $h=0; for($i=0;$i< $textlength ;$i++) { $draw->annotation(0, $h, substr($VAR_txt,$i,1)); $h+=$tmp_metrics['ascender'] * $VAR_line_height; } $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_top_text_upper($layer, $engraved, $text_angle) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; //$VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; //$VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; //$VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_shadow_color = "black"; // always use black for now // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); if($engraved) { $draw->setFillColor($VAR_color); } else { $draw->setFillColor($VAR_em_color); } //$draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1); //$ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 1; //$ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } if($engraved) { $draw->setFillColor($VAR_shadow_color); } else { $draw->setFillColor($VAR_color); } $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); $tmp_txt_Canvas->drawImage($draw); $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * $text_angle; //$VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array($text_angle, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_top_text_lower($layer, $engraved) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; //$VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; //$VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; //$VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_shadow_color = "black"; // always use black for now $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); if($engraved) { $draw->setFillColor($VAR_color); } else { $draw->setFillColor($VAR_em_color); } //$draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1); //$ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 1; //$ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } if($engraved) { $draw->setFillColor($VAR_shadow_color); } else { $draw->setFillColor($VAR_color); } $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); $tmp_txt_Canvas->drawImage($draw); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 180; //$VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(180, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_text_Wave($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); $VAR_wave_height = isset($layer['wave_height']) ? $layer['wave_height'] : 0; // Parameters of wave height and direction // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_length < 3) { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 30, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } $tmp_txt_Canvas->waveImage($VAR_wave_height, $tmp_txt_Canvas->getImageWidth()); //$imagick->waveImage($amplitude, $length); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Inside Engraving Text function FUNC_text_Arc_5($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($salpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = 0; $sy = 0; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = $text_xoffset; $ty = $text_yoffset; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_top_text_2($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = "#ffffff"; //$VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; $VAR_txt_2 = " ".$VAR_txt_2." "; if($VAR_star_size > 0) { if((strlen($VAR_txt_2) - 2) == 0) { $VAR_side_padding = 0; }elseif((strlen($VAR_txt_1) - 2) == 0) { $VAR_side_padding = -1; } } $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); // Shadow $draw->setFillColor($VAR_em_color); $draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), -$i + 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation(-$tmp_metrics['D']['textWidth'] - $tmp_metrics['U']['textWidth'] - 1 - ($VAR_side_padding * 3), 3 - $tmp_metrics['D']['textHeight'], $VAR_txt_2); $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; if((strlen($VAR_txt_2) - 2) == 0) { FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($tmp_metrics['D']['textWidth'] / 2) - ($VAR_star_size * 8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }elseif((strlen($VAR_txt_1) - 2) == 0) { FUNC_starator($draw_star, ($tmp_metrics['U']['textWidth'] / 2) - ($VAR_star_size * 9.2), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; }else{ FUNC_starator($draw_star, - ($VAR_star_size * 8.4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] - ($VAR_star_size * 4), $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; } if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } // Text Engraving New function FUNC_text_Arc_New_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_New_1b($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); /////////////////////////////// $points = array( 60,20, 0,0, -60,60 ); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_POLAR, $points, true); ////////////////////////////////// if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_1a($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_New_1c($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //$xshade = isset($layer['xshade']) ? $layer['xshade'] : 45; //$yshade = isset($layer['yshade']) ? $layer['yshade'] : 20; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script MT"; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 0; $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontWeight(800); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); //$draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); //$draw1->annotation($sx, $sy, $VAR_txt[1]) $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0.2); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //$tmp_txt_Canvas->shadeImage(false, 10,50); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_tile_effects($tmp_txt_IMG, $width, $height, $type = 1) { //if(!empty($tmp_txt_IMG)) { $tmp_GEO = $tmp_txt_IMG->getImageGeometry(); //if($tmp_GEO['width'] > $width) { $width = $tmp_GEO['width']; //} //} $tile_IMG = new Imagick(); $tile_IMG->newImage($width, $height, new ImagickPixel("none")); if($type == 1) { $tile_IMG->compositeImage( $tmp_txt_IMG, imagick::COMPOSITE_DEFAULT, 0,0); $tile_IMG->compositeImage( $tmp_txt_IMG, imagick::COMPOSITE_DEFAULT, $height/2 - 10, $height/2 - 10); } else { $tile_IMG->compositeImage( $tmp_txt_IMG, imagick::COMPOSITE_DEFAULT, 0,0); } return $tile_IMG; } function FUNC_text_tile($layer,$tmp_txt_IMG) { global $core_width, $core_height; $img_width = isset($layer['width']) ? $layer['width'] : $core_width; $img_height = isset($layer['height']) ? $layer['height'] : $core_height; $img_tile_width = isset($layer['tile_width']) ? $layer['tile_width'] : $core_width; $img_tile_height = isset($layer['tile_height']) ? $layer['tile_height'] : $core_height; $img_tile_type = isset($layer['tile_type']) ? $layer['tile_type'] : 1; $tile_IMG = FUNC_text_tile_effects($tmp_txt_IMG, $img_tile_width, $img_tile_height, $img_tile_type); $tiled_IMG = new Imagick(); $tiled_IMG->newImage($img_width, $img_height, new ImagickPixel("none")); //$tmp_texture = new Imagick($tile_IMG); $tmp_txt_IMG = $tiled_IMG->textureImage($tile_IMG); $tile_IMG->destroy(); return $tmp_txt_IMG; } function FUNC_3_text_star($layer) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_txt_3 = $VAR_txt = isset($layer['txt_3']) ? $layer['txt_3'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : $core_height; $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; $VAR_text_offset = isset($layer['text_offset']) ? $layer['text_offset'] : 0; $VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; $VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 2; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas //$VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas //$VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; $VAR_txt_2 = " ".$VAR_txt_2." "; $VAR_txt_3 = " ".$VAR_txt_3." "; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); $draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $ln = strlen($VAR_txt_1) + strlen($VAR_txt_2) + strlen($VAR_txt_3); $ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $tmp_metrics['P'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_3); $metrics_width_all = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + $tmp_metrics['P']['textWidth']; $VAR_side_padding = ($VAR_width - $metrics_width_all)/6; if($VAR_side_padding < 10) { $VAR_side_padding = 10; } $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + $tmp_metrics['P']['textWidth'] + ($VAR_side_padding * 6); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight'],$tmp_metrics['P']['textHeight']); $VAR_txt_y = ($VAR_height - $VAR_txt_height)/2; if($VAR_txt_width > $VAR_width) { $VAR_xscale = $VAR_width/$VAR_txt_width; $VAR_width = $VAR_txt_width; } $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding - $VAR_text_offset, $VAR_txt_y+$i, $VAR_txt_1); } $draw->setFillColor($VAR_color); $draw->annotation($VAR_side_padding - $VAR_text_offset, $VAR_txt_y, $VAR_txt_1); // Shadow $draw->setFillColor($VAR_em_color); //$draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3) - $VAR_text_offset, $VAR_txt_y+$i, $VAR_txt_2); } $draw->setFillColor($VAR_color); $draw->annotation($tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 3) - $VAR_text_offset, $VAR_txt_y, $VAR_txt_2); // Shadow $draw->setFillColor($VAR_em_color); //$draw->rotate(180); for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 5) - $VAR_text_offset, $VAR_txt_y+$i, $VAR_txt_3); } $draw->setFillColor($VAR_color); $draw->annotation($tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 5) - $VAR_text_offset, $VAR_txt_y, $VAR_txt_3); $tmp_txt_Canvas->drawImage($draw); if($VAR_star_size > 0) { $draw_star = new ImagickDraw(); $go_star = false; FUNC_starator($draw_star, - ($VAR_star_size * 8.4) - $VAR_text_offset, $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $VAR_txt_width - ($VAR_star_size * 8.8) - $VAR_text_offset, $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + ($VAR_side_padding * 2) - ($VAR_star_size * 8.8) - $VAR_text_offset, $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); FUNC_starator($draw_star, $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4) - ($VAR_star_size * 8.8) - $VAR_text_offset, $VAR_star_y, $VAR_star_size, $VAR_emb_depth, $VAR_color,$VAR_em_color); $go_star = true; if($go_star) $tmp_txt_Canvas->drawImage($draw_star); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_txt_width)*$VAR_xscale, ($VAR_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * 360; // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width)*$VAR_xscale, ($VAR_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if($VAR_align == "center"){ $left_offset = $VAR_PL + ($core_width - $VAR_txt_width - $VAR_PL - $VAR_PR) / 2; }elseif($VAR_align == "right"){ $left_offset = $core_width - $VAR_PR - $VAR_txt_width; } else { $left_offset = $VAR_PL; } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $left_offset, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, 0); if(isset($tmp_Clone)) $tmp_Clone->destroy(); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_name_text_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); if(strlen($VAR_txt) > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $VAR_kern = -2; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[strlen($VAR_txt)-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[strlen($VAR_txt)-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $VAR_kern = -2; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $VAR_kern = -2; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 20; $i <= $tmp_metrics['textHeight']; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); /* //get position of left chain hook if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'P') { // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_WEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 20; $i <= $tmp_metrics['textHeight']; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } } else { for ($i = 0; $i <= $VAR_width_first; $i++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $hookrighty; $hookleftx = $i; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); */ } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $VAR_kern = -2; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} /* for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } */ } $draw->clear(); $tmp_txt_Canvas->clear(); } //$tmp_txt_Canvas = new Imagick(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $VAR_kern = -2; $draw->setTextKerning($VAR_kern); //$draw->setTextAlignment(imagick::ALIGN_CENTER); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; if($tmp_metrics['textWidth'] > $VAR_width) { $VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { $VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } /* if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } */ // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); //$fontStretch = STRETCH_ULTRACONDENSED; //$fontStretch = STRETCH_EXTRAEXPANDED; //$draw->setFontStretch($fontStretch); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); /* echo '
'; print_r($tmp_metrics); echo ''; exit; */ if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 10, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } //$tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); $img_hook = $PATH_components.'pendants/hook24.png'; $tmp_hook = new Imagick($img_hook); if(strlen($VAR_txt) > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - 18); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 6, $hooklefty*$hook_adjust_factor - 24); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 6, $hooklefty*$hook_adjust_factor - 20); } } if(strlen($VAR_txt) > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - 3, $hookrighty*$hook_adjust_factor - 12); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 18); } } $tmp_hook->clear(); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width)*$VAR_xscale, ($VAR_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_AFFINE , array(0,0,0,0 , 0,10,10,10 , 10,0,10,0), false); //$degrees = 3*$VAR_length; //$degrees = array( 5*$VAR_length, 0, 600, 500 ); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $degrees, true); //$tmp_txt_Canvas->evaluateImage(Imagick::EVALUATE_MULTIPLY, 0.5, Imagick::CHANNEL_ALPHA); //$tmp_txt_Canvas->waveImage(-20, 100); //$controlPoints = array(0,0,3,0,0,46,10,46,70,0,70,7,70,46,60,40); //$tmp_txt_Canvas->distortImage( Imagick::DISTORTION_PERSPECTIVE , $controlPoints, false ); //$tmp_txt_Canvas->distortImage( Imagick::DISTORTION_ARC , array(9, 0, 50), false ); //$draw2 = new ImagickDraw(); //$tmp_txt_Canvas->drawImage($draw2); /* if(isset($layer['tile'])) { $tmp_Canvas = $tmp_Canvas->textureImage($tmp_txt_Canvas); $img_x = 0; $img_y = 0; }else{ $tmp_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, 0, 0); } */ $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(70,60,100); //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if(strlen($VAR_txt) > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1.5, $VAR_PT+1.5); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $img_chain_left = $PATH_components.'pendants/left-chain.png'; $tmp_chain_left = new Imagick($img_chain_left); $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $img_chain_right = $PATH_components.'pendants/right-chain.png'; $tmp_chain_right = new Imagick($img_chain_right); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_width - ($VAR_width_last*$hook_adjust_factor) + 120, $hookrighty*$hook_adjust_factor - 142); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $img_chain_right = $PATH_components.'pendants/right-chain.png'; $tmp_chain_right = new Imagick($img_chain_right); $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 48, $hooklefty - 153); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1.5, $VAR_PT+1.5); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $img_chain_left = $PATH_components.'pendants/left-chain.png'; $tmp_chain_left = new Imagick($img_chain_left); $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 110, $hooklefty*$hook_adjust_factor - 153); } $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_2($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); //$tmp_txt_Canvas->shadeImage(false, 60,150); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_dynamic_1($layer) { global $PATH_components, $core_width, $core_height, $txt_dynamic_position; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $VAR_PL = $txt_dynamic_position[0]; $VAR_PT = $txt_dynamic_position[1]; $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_3($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_3a($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New with adjustment for bleeding on edges of Cochin font function FUNC_text_Arc_New_3b($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 30, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_orig_height + 30, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+30)*$VAR_xscale, ($VAR_height+30)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_Arc_New_3c($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add substring attribute to text $VAR_substring = isset($layer['substring']) ? $layer['substring'] : ""; if($VAR_substring != "") { if($VAR_substring == "first") { if(strlen($VAR_txt) > 1) { $VAR_txt = substr($VAR_txt, 0, 1); } else { $VAR_txt = ""; } } else if($VAR_substring == "last") { if(strlen($VAR_txt) > 1) { $VAR_txt = substr($VAR_txt, -1); } else { $VAR_txt = ""; } } else if($VAR_substring == "middle") { if(strlen($VAR_txt) == 1) { $VAR_txt = substr($VAR_txt, 0, 1); } else { $VAR_txt = substr($VAR_txt, 1, strlen($VAR_txt)-2); } } else if(is_numeric($VAR_substring)) { $VAR_txt = substr($VAR_txt, $VAR_substring, 1); } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas $VAR_flip = isset($layer['flip']) ? $layer['flip'] : ""; // Flip canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } if($VAR_flip != "") { if($VAR_flip == "horizontal") { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 270); $tmp_txt_Canvas->flipImage(); $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } else { $tmp_txt_Canvas->flipImage(); } } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New with more adjustments for bleeding on edges of Cochin font function FUNC_text_Arc_New_3d($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 70, new ImagickPixel("#fff9d0")); $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 70, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 70, new ImagickPixel("#fff9d0")); $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_orig_height + 70, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+30)*$VAR_xscale, ($VAR_height+30)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_top_text_upper2($layer, $engraved, $text_angle) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; //$VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; //$VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; //$VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_shadow_color = "black"; // always use black for now $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); if($engraved) { $draw->setFillColor($VAR_color); } else { $draw->setFillColor($VAR_em_color); } //$draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1); //$ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 1; //$ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } if($engraved) { $draw->setFillColor($VAR_shadow_color); } else { $draw->setFillColor($VAR_color); } $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); $tmp_txt_Canvas->drawImage($draw); $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * $text_angle; //$VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array($text_angle, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_name_text_new_1($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } if($VAR_txt[$VAR_length-1] == "m" || $VAR_txt[$VAR_length-1] == "r" ||$VAR_txt[$VAR_length-1] == "t" ) { $hookrightx = 30; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18, $hooklefty*$hook_adjust_factor - $chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname == "HELVETI1") { if($VAR_txt[$VAR_length-1] == "S" || $VAR_txt[$VAR_length-1] == "O") { $hooklefty = 28; $hookleftx = 4; } $no_asc = array("G","F","C"); $first_char = array("H"); if (in_array($VAR_txt[$VAR_length-1], $no_asc)) { if (in_array($VAR_txt[0], $first_char)) { $hookleftx = 2; $hooklefty = 18; } } } if($VAR_fontname !== "Harlow Solid Italic" ) { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } if($VAR_fontname == "Commercial") { $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("R","T","H","P","S","U","V","W","X","E"); if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 53; $hooklefty = 42; } else if($VAR_txt[0] == "Z") { $hookleftx = 41; } } $first_char_position1 = array("M","W"); if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position1)) { $hookleftx = 50; //$hooklefty = 42; } else if($VAR_txt[0] == "Z") { $hookleftx = 10; $hooklefty = 5; } } if($VAR_txt[$VAR_length-1] == "j") { $hookrightx = 88; $hooklefty = 55; $hookleftx = 55; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $metal_code =''; $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } if(isset($layer['metal']['code']) && $productid == 90387 ) { $metal_code = $layer['metal']['code']; $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$metal_code.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$metal_code.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1u($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; //print_r($tmp_metrics); exit; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //print_r($tmp_txt_Canvas);exit; //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); //print_r($pixel);exit; $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; //print_r($tmp_metrics);exit; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } $hooklefty = 40; $hookleftx = 7; if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $hookrighty = 40; $hookrightx = 36; //echo $hookrighty.'///'.$hookrightx;exit; $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "HELVETI1") { if($VAR_txt[$VAR_length-1] == "L"){ $hookrightx = 20; } else if($VAR_txt[$VAR_length-1] == "I"){ $hookrightx = 24; } else if($VAR_txt[$VAR_length-1] == "M"){ $hookrightx = 52; } else if($VAR_txt[$VAR_length-1] == "T"){ $hookrightx = 32; } else if($VAR_txt[$VAR_length-1] == "W"){ $hookrightx = 53; } } elseif($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "L") { $hookleftx = -120; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1c($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 60; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 60; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-7, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust+2, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Adjusted from FUNC_name_text_new_1b to use 30px hook function FUNC_name_text_new_1d($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 10, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript" ) { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-12, $hooklefty - 8); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-10, $hooklefty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-10, $hooklefty - 10); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 5, $hookrighty - 8); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 8, $hookrighty - 21); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1e($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 22; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 35; } if($VAR_fontname == "HELVETI1") { $hookrightx = 42; $hookleftx = 5; if ($hookleftx > 16) { $hookleftx = 16; } } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 12); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 12); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 10); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 23); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //For large size fonts, ex. 150 function FUNC_name_text_new_1f($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "n" || $VAR_txt[$VAR_length-1] == "u") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { //$hookrightx = 70; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } if(isset($layer['metal']['code']) && $productid == 90387) { $metal_code = $layer['metal']['code']; $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$metal_code.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$metal_code.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 18); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 23); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 18); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust-5, $hookrighty - 17); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 30); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+4, $VAR_PT+4); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with fixed charm/birthstone below name function FUNC_name_text_new_1g($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); // Add hook for charm/stone below the name $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_width/2 + 2, $VAR_height*0.83); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1h($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_NORTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry Adjustment for 10px Hook function FUNC_name_text_new_1i($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Brush Script Std") { if($VAR_txt[$VAR_length-1] == "y") { //$hookrighty += 5; $hookrightx += 15; } } if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 22; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 35; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $hook_name = $f_tmp['filename']; /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($hook_name = "hook10") { $hookleftx_adjust = 3; $hookrightx_adjust = 7; $hooklefty_adjust1 = 6; $hooklefty_adjust2 = 9; $hookrighty_adjust1 = 7; $hookrighty_adjust2 = 12; } else { $hookleftx_adjust = 5; $hookrightx_adjust = 13; $hooklefty_adjust1 = 12; $hooklefty_adjust2 = 17; $hookrighty_adjust1 = 10; $hookrighty_adjust2 = 23; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - $hookleftx_adjust, $hooklefty - $hooklefty_adjust1); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - $hooklefty_adjust2); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - $hooklefty_adjust1); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - $hookrighty_adjust1); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - $hookrightx_adjust, $hookrighty - $hookrighty_adjust2); } } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 12); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 12); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 10); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 23); } } */ $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(65,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+0.5, $VAR_PT+1.5); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+0.5, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+0.5, $VAR_PT+0.5); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+0.5, $VAR_PT-0.5); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 10, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with fixed charm/birthstone below name and adjustment for Cochin font function FUNC_name_text_new_1j($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } else if($VAR_fontname == "Cochin") { if($hookrighty < 15) { $hookrighty = 15; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else if($VAR_fontname == "Cochin") { if ($hookleftx < 20) { $hookleftx = 20; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { if($VAR_fontname == "Cochin") { $draw->setGravity(Imagick::GRAVITY_NORTH); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("#fffcd2")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); // Add hook for charm/stone below the name $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_width/2 + 2, $VAR_height*0.83 - 15); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 6, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start image attached to chain and no left hook function FUNC_name_text_new_1k($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; /* echo '
'; print_r($VAR_size); echo ''; exit; */ //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } */ if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ if($VAR_txt[0] == 'A') { $hookleftx = 16; $hooklefty = 8; } else if($VAR_txt[0] == 'B' || $VAR_txt[0] == 'D' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'K' || $VAR_txt[0] == 'P' || $VAR_txt[0] == 'R' || $VAR_txt[0] == 'T' || $VAR_txt[0] == 'U') { $hookleftx = -12; $hooklefty = -2; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'F' || $VAR_txt[0] == 'H') { $hookleftx = -6; $hooklefty = -2; } else if($VAR_txt[0] == 'J') { $hookleftx = -10; $hooklefty = 2; } else if($VAR_txt[0] == 'L') { $hookleftx = 12; $hooklefty = 6; } else if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'N' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'X' || $VAR_txt[0] == 'Y' || $VAR_txt[0] == 'Z') { $hookleftx = -20; $hooklefty = 1; } else if($VAR_txt[0] == 'O' || $VAR_txt[0] == 'V') { $hookleftx = -12; $hooklefty = 3; } else { //$VAR_txt[0] == C,G,Q,S $hookleftx = 0; $hooklefty = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start image attached to chain and with end image and no left hook function FUNC_name_text_new_1l($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_ascender = $tmp_metrics['ascender']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_width = $tmp_metrics['textWidth']; $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_ascender = $tmp_metrics['ascender']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } */ if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ if($VAR_txt[0] == 'A') { $hookleftx = 16; $hooklefty = 8; } else if($VAR_txt[0] == 'B' || $VAR_txt[0] == 'D' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'K' || $VAR_txt[0] == 'P' || $VAR_txt[0] == 'R' || $VAR_txt[0] == 'T' || $VAR_txt[0] == 'U') { $hookleftx = -12; $hooklefty = -2; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'F' || $VAR_txt[0] == 'H') { $hookleftx = -6; $hooklefty = -2; } else if($VAR_txt[0] == 'J') { $hookleftx = -10; $hooklefty = 2; } else if($VAR_txt[0] == 'L') { $hookleftx = 12; $hooklefty = 6; } else if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'N' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'X' || $VAR_txt[0] == 'Y' || $VAR_txt[0] == 'Z') { $hookleftx = -20; $hooklefty = 1; } else if($VAR_txt[0] == 'O' || $VAR_txt[0] == 'V') { $hookleftx = -12; $hooklefty = 3; } else { //$VAR_txt[0] == C,G,Q,S $hookleftx = 0; $hooklefty = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // End Scroll image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $tmp_end_img_width = $tmp_end_img->getImageWidth(); $VAR_end_img_x = isset($layer['end_img_x']) ? $layer['end_img_x'] : 0; $VAR_end_img_y = isset($layer['end_img_y']) ? $layer['end_img_y'] : 0; if((isset($VAR_fit) && $VAR_fit == 2)) { $tmp_txt_Canvas->compositeImage($tmp_end_img, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width - (($VAR_width - $VAR_new_width)/2) - $tmp_end_img_width + $VAR_end_img_x, $VAR_PT + $VAR_new_ascender + $VAR_end_img_y); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width - (($VAR_width - $VAR_orig_width)/2) - $tmp_end_img_width + $VAR_end_img_x, $VAR_PT + $VAR_ascender + $VAR_end_img_y); } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); $tmp_end_img->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start and end images attached to chains and no hooks function FUNC_name_text_new_1m($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_ascender = $tmp_metrics['ascender']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_ascender = $tmp_metrics['ascender']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; //$tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); */ // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ if($VAR_txt[0] == 'A') { $hookleftx = 16; $hooklefty = 8; } else if($VAR_txt[0] == 'B' || $VAR_txt[0] == 'D' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'K' || $VAR_txt[0] == 'P' || $VAR_txt[0] == 'R' || $VAR_txt[0] == 'T' || $VAR_txt[0] == 'U') { $hookleftx = -12; $hooklefty = -2; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'F' || $VAR_txt[0] == 'H') { $hookleftx = -6; $hooklefty = -2; } else if($VAR_txt[0] == 'J') { $hookleftx = -10; $hooklefty = 2; } else if($VAR_txt[0] == 'L') { $hookleftx = 12; $hooklefty = 6; } else if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'N' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'X' || $VAR_txt[0] == 'Y' || $VAR_txt[0] == 'Z') { $hookleftx = -20; $hooklefty = 1; } else if($VAR_txt[0] == 'O' || $VAR_txt[0] == 'V') { $hookleftx = -12; $hooklefty = 3; } else { //$VAR_txt[0] == C,G,Q,S $hookleftx = 0; $hooklefty = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); if((isset($VAR_fit) && $VAR_fit == 2)) { $chain_left_y = $VAR_PT - $tmp_chain_left->getImageHeight() + $VAR_new_ascender; } else { $chain_left_y = $VAR_PT - $tmp_chain_left->getImageHeight() + $VAR_orig_ascender; } //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); //$chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $chain_right_y = $VAR_PT - $tmp_chain_right->getImageHeight() + $VAR_new_ascender; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $chain_right_y + $VAR_chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $chain_right_y = $VAR_PT - $tmp_chain_right->getImageHeight() + $VAR_orig_ascender; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start image attached to chain and no left hook function FUNC_name_text_new_1n($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } */ if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ if($VAR_txt[0] == 'A') { $hookleftx = 10; $hooklefty = 10; } else if($VAR_txt[0] == 'B' || $VAR_txt[0] == 'D' || $VAR_txt[0] == 'R') { $hookleftx = -8; $hooklefty = 0; } else if($VAR_txt[0] == 'C' || $VAR_txt[0] == 'G') { $hookleftx = -10; $hooklefty = 10; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'F') { $hookleftx = -8; $hooklefty = 3; } else if($VAR_txt[0] == 'H' || $VAR_txt[0] == 'I') { $hookleftx = -6; $hooklefty = 0; } else if($VAR_txt[0] == 'J') { $hookleftx = -10; $hooklefty = 6; } else if($VAR_txt[0] == 'K' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'X') { $hookleftx = -4; $hooklefty = 0; } else if($VAR_txt[0] == 'L') { $hookleftx = 0; $hooklefty = 10; } else if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'Y') { $hookleftx = -6; $hooklefty = 0; } else if($VAR_txt[0] == 'N' || $VAR_txt[0] == 'Q') { $hookleftx = -2; $hooklefty = 0; } else if($VAR_txt[0] == 'O') { $hookleftx = -6; $hooklefty = 4; } else if($VAR_txt[0] == 'P') { $hookleftx = -14; $hooklefty = 0; } else if($VAR_txt[0] == 'T') { $hookleftx = 4; $hooklefty = -4; } else { //$VAR_txt[0] == S,U,V,Z $hookleftx = 0; $hooklefty = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start image attached to chain and with end image and no left hook function FUNC_name_text_new_1o($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_ascender = $tmp_metrics['ascender']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_width = $tmp_metrics['textWidth']; $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_ascender = $tmp_metrics['ascender']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } */ if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ //Adjustments for position of left chain with image $hooklefty = 0; if($VAR_txt[0] == 'C') { $hookleftx = -4; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'J' || $VAR_txt[0] == 'K' || $VAR_txt[0] == 'M' || $VAR_txt[0] == 'U' || $VAR_txt[0] == 'V' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'Y' || $VAR_txt[0] == 'Z') { $hookleftx = 4; } else if($VAR_txt[0] == 'F' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'N') { $hookleftx = 8; } else if($VAR_txt[0] == 'H' || $VAR_txt[0] == 'S' || $VAR_txt[0] == 'T') { $hookleftx = 6; } else if($VAR_txt[0] == 'A' || $VAR_txt[0] == 'L') { $hookleftx = 2; } else { //$VAR_txt[0] == S,U,V,Z $hookleftx = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // End Scroll image $f_tmp = pathinfo($layer['right_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_right_img = new Imagick($img_right); $tmp_right_img_width = $tmp_right_img->getImageWidth(); $VAR_right_img_x = isset($layer['right_img_x']) ? $layer['right_img_x'] : 0; $VAR_right_img_y = isset($layer['right_img_y']) ? $layer['right_img_y'] : 0; if((isset($VAR_fit) && $VAR_fit == 2)) { $tmp_txt_Canvas->compositeImage($tmp_right_img, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width - (($VAR_width - $VAR_new_width)/2) - $tmp_right_img_width + $VAR_right_img_x, $VAR_PT + $VAR_new_ascender + $VAR_right_img_y); } else { $tmp_txt_Canvas->compositeImage($tmp_right_img, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width - (($VAR_width - $VAR_orig_width)/2) - $tmp_right_img_width + $VAR_right_img_x, $VAR_PT + $VAR_ascender + $VAR_right_img_y); } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); $tmp_right_img->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with start and end images attached to chains and no hooks function FUNC_name_text_new_1p($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_ascender = $tmp_metrics['ascender']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_width = $tmp_metrics['textWidth']; $VAR_new_ascender = $tmp_metrics['ascender']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("#fbf9cc")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; //$tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /* if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); */ // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of left chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ /* if($VAR_txt[0] == 'A') { $hookleftx = 16; $hooklefty = 8; } else if($VAR_txt[0] == 'B' || $VAR_txt[0] == 'D' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'K' || $VAR_txt[0] == 'P' || $VAR_txt[0] == 'R' || $VAR_txt[0] == 'T' || $VAR_txt[0] == 'U') { $hookleftx = -12; $hooklefty = -2; } else if($VAR_txt[0] == 'E' || $VAR_txt[0] == 'F' || $VAR_txt[0] == 'H') { $hookleftx = -6; $hooklefty = -2; } else if($VAR_txt[0] == 'J') { $hookleftx = -10; $hooklefty = 2; } else if($VAR_txt[0] == 'L') { $hookleftx = 12; $hooklefty = 6; } else if($VAR_txt[0] == 'M' || $VAR_txt[0] == 'N' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'X' || $VAR_txt[0] == 'Y' || $VAR_txt[0] == 'Z') { $hookleftx = -20; $hooklefty = 1; } else if($VAR_txt[0] == 'O' || $VAR_txt[0] == 'V') { $hookleftx = -12; $hooklefty = 3; } else { //$VAR_txt[0] == C,G,Q,S $hookleftx = 0; $hooklefty = 0; } */ $hooklefty = 0; if($VAR_txt[0] == 'A' || $VAR_txt[0] == 'L') { $hookleftx = 16; } else if($VAR_txt[0] == 'E') { $hookleftx = 6; } else if($VAR_txt[0] == 'F' || $VAR_txt[0] == 'G' || $VAR_txt[0] == 'J' || $VAR_txt[0] == 'Q' || $VAR_txt[0] == 'S') { $hookleftx = 2; $hooklefty = 2; } else if($VAR_txt[0] == 'H' || $VAR_txt[0] == 'I' || $VAR_txt[0] == 'R' || $VAR_txt[0] == 'U' || $VAR_txt[0] == 'V') { $hookleftx = 0; $hooklefty = 2; } else if($VAR_txt[0] == 'N' || $VAR_txt[0] == 'O' || $VAR_txt[0] == 'P' || $VAR_txt[0] == 'T') { $hookleftx = 2; } else { $hookleftx = 0; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); if((isset($VAR_fit) && $VAR_fit == 2)) { $chain_left_y = $VAR_PT - $tmp_chain_left->getImageHeight() + $VAR_new_ascender; } else { $chain_left_y = $VAR_PT - $tmp_chain_left->getImageHeight() + $VAR_orig_ascender; } //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty + $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); //$chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $chain_right_y = $VAR_PT - $tmp_chain_right->getImageHeight() + $VAR_new_ascender; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_center_adjust + $VAR_new_width + $VAR_chain_right_x, $chain_right_y + $VAR_chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $chain_right_y + $VAR_chain_right_y); } else { $chain_right_y = $VAR_PT - $tmp_chain_right->getImageHeight() + $VAR_orig_ascender; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of right chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Modified for SweetheartScript font function FUNC_name_text_new_1q($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= $VAR_width_last/2; $j--) { //for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_NORTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 15, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 40, new ImagickPixel("#fbf7c6")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 40, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 7); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 2); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 15); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 15); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 17); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 12); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 10); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 15); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Modified for Jenna Sue Font function FUNC_name_text_new_1r($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= $VAR_width_last*0.48; $j--) { //for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); //Set minimum vakue of Right hook y-position if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } else if($VAR_fontname == "CPS-1140") { if($hookrighty < 20) { $hookrighty = 20; } } // Manual position of Right Hook for last character if($VAR_fontname == "CPS-1140") { if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 36; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 10; $hookrighty = 40; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } } else { if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } /* // Manual position of Right Hook for last character if($VAR_fontname == "CPS-1140") { if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 36; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 10; $hookrighty = 40; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } } else { if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } } */ // Manual position of Left Hook for first character if($VAR_fontname == "CPS-1140") { if($VAR_txt[0] == "A") { $hookleftx = 25; $hooklefty = 23; } else if($VAR_txt[0] == "B") { $hookleftx = 26; $hooklefty = 26; } else if($VAR_txt[0] == "D") { $hookleftx = 26; $hooklefty = 28; } else if($VAR_txt[0] == "F") { $hookleftx = 20; $hooklefty = 24; } else if($VAR_txt[0] == "H") { $hookleftx = 20; $hooklefty = 22; } else if($VAR_txt[0] == "I") { $hookleftx = 20; $hooklefty = 30; } else if($VAR_txt[0] == "K") { $hookleftx = 20; $hooklefty = 20; } else if($VAR_txt[0] == "L") { $hookleftx = 42; $hooklefty = 20; } else if($VAR_txt[0] == "M") { $hookleftx = 24; $hooklefty = 22; } else if($VAR_txt[0] == "N") { $hookleftx = 24; $hooklefty = 22; } else if($VAR_txt[0] == "P") { $hookleftx = 24; $hooklefty = 26; } else if($VAR_txt[0] == "Q") { $hookleftx = 18; $hooklefty = 28; } else if($VAR_txt[0] == "R") { $hookleftx = 24; $hooklefty = 24; } else if($VAR_txt[0] == "S") { $hookleftx = 26; $hooklefty = 26; } else if($VAR_txt[0] == "T") { $hookleftx = 26; $hooklefty = 26; } else if($VAR_txt[0] == "U") { $hookleftx = 26; $hooklefty = 30; } else if($VAR_txt[0] == "V") { $hookleftx = 26; $hooklefty = 24; } else if($VAR_txt[0] == "W") { $hookleftx = 26; $hooklefty = 28; } else if($VAR_txt[0] == "X") { $hookleftx = 26; $hooklefty = 28; } else if($VAR_txt[0] == "Y") { $hookleftx = 26; $hooklefty = 24; } } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_NORTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 10); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 10); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Modified for CPS-1119 font function FUNC_name_text_new_1s($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= $VAR_width_last/2; $j--) { //for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_NORTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 25, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 50, new ImagickPixel("#fbf7c6")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 50, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty + 10); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty + 3); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty + 8); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty + 10); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 24); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 23); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 9); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 4); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 19); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 24); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Modified for Handstamp CPS-1118 font function FUNC_name_text_new_1t($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= $VAR_width_last/2; $j--) { //for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } if($hookrighty > $hooklefty) { //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } } else if($hooklefty > $hookrighty) { $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of last character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as left hook $i = $hooklefty; for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_NORTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 15, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 40, new ImagickPixel("#fbf7c6")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 40, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust+5, $hooklefty-5); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust+8, $hooklefty-20); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 7); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 2); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty+2); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if($VAR_length > 1) { /* //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); */ //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 12); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 17); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 17); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 12); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 10); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y + 15); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_2($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, 94); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, 74); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, 74); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, 102); } // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_left_bottom->clear(); $tmp_right_bottom->clear(); $tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_heart($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } if($VAR_txt[$VAR_length-1] == "m" || $VAR_txt[$VAR_length-1] == "r" ||$VAR_txt[$VAR_length-1] == "t" ) { $hookrightx = 63; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, 94); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, 74); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, 74); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, 102); } // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_left_bottom->clear(); $tmp_right_bottom->clear(); $tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //name jewelry text with bottom image function FUNC_name_text_new_2a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_left_bottom->clear(); $tmp_right_bottom->clear(); $tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_2b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = $VAR_width_last; $i >= 0; $i--) { for ($j = $tmp_metrics['textHeight']; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $j); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $i; $hookrighty = $j; break 2; } } } /* //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } */ $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 40, $hooklefty - 20); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 20); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text $f_tmp = pathinfo($layer['bottom_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Compute width of bottom image $bottom_image_width = $tmp_metrics['textWidth'] - 20; $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2), $bottom_image_y + 15); /* //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //name jewelry text with bottom image modified to adjust Top location function FUNC_name_text_new_2c($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { if($layer['font'] == "CPS-1116") { $hookrightx = 60; } else { $hookrightx = 90; } } else if($VAR_txt[$VAR_length-1] == "r") { if($layer['font'] == "CPS-1116") { $hookrightx = 35; } else { $hookrightx = 50; } } else if($VAR_txt[$VAR_length-1] == "t") { if($layer['font'] == "CPS-1116") { $hookrightx = 25; } else { $hookrightx = 40; } $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "u") { if($layer['font'] == "CPS-1116") { $hookrightx = 40; } } else if($VAR_txt[$VAR_length-1] == "w") { if($layer['font'] == "CPS-1116") { $hookrightx = 55; } else { $hookrightx = 85; } } else if($VAR_txt[$VAR_length-1] == "x") { if($layer['font'] == "CPS-1116") { $hookrightx = 43; } else { $hookrightx = 50; } } else if($VAR_txt[$VAR_length-1] == "y") { if($layer['font'] == "CPS-1116") { $hookrightx = 40; } else { $hookrightx = 62; } } else if($VAR_txt[$VAR_length-1] == "z") { if($layer['font'] == "CPS-1116") { $hookrightx = 35; } else { $hookrightx = 52; } } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; //Adjustment for width of bottom image for some letters if($VAR_txt[0] == 'N' || $VAR_txt[0] == 'U' || $VAR_txt[0] == 'W') { $bottom_image_width -= 5; } else if($VAR_txt[0] == 'V') { $bottom_image_width -= 12; } $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { //Adjustment for position of bottom image for some letters if($VAR_txt[0] == 'N' || $VAR_txt[0] == 'U' || $VAR_txt[0] == 'W' || $VAR_txt[0] == 'V') { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 18, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 20, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 16, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $VAR_PT; //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_left_bottom->clear(); $tmp_right_bottom->clear(); $tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //name jewelry text with end image and bottom image function FUNC_name_text_new_3($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $hookrightx += 25; $hookrighty = 35; $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "l") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "s") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 78; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust+15, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 15, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); // End Scroll image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); if($endimg_resize) { $tmp_end_img->resizeImage($tmp_end_img->getImageWidth()*0.9, $tmp_end_img->getImageHeight()*0.9, Imagick::FILTER_LANCZOS, 1); } // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20 + 30, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 3) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 20-15, 92); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 22-15, 72); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 18-15, 72); if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 14); } } // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, -30, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses $tmp_left_bottom->clear(); $tmp_right_bottom->clear(); $tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //with bottom image below name and transform function FUNC_name_text_new_3a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_max_text_width = isset($layer['max_text_width']) ? $layer['max_text_width'] : $core_width; // Text Canvas Width // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // Distortion Parameters $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } else if($VAR_fontname == "Cochin") { if($hookrighty < 15) { $hookrighty = 15; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else if($VAR_fontname == "Cochin") { if ($hookleftx < 20) { $hookleftx = 20; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u" || $VAR_txt[$VAR_length-1] == "y") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { if($VAR_fontname == "Cochin") { $draw->setGravity(Imagick::GRAVITY_NORTH); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); //$draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } //$draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas if($VAR_align == 'left') { $draw->annotation(10, 0, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); } // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("#fffcd2")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } //Resize text if exceed maximum width $text_canvas_width = $tmp_txt_Canvas->getImageWidth(); $text_canvas_height = $tmp_txt_Canvas->getImageHeight(); $text_width_adjust = 0; $righthookx_adjust = 0; //$VAR_xscale = 352/$VAR_orig_width; if($VAR_orig_width > $VAR_max_text_width) { $text_width_adjust = $VAR_orig_width - $VAR_max_text_width; $tmp_txt_Canvas->resizeImage($text_canvas_width - $text_width_adjust, $VAR_new_height, imagick::FILTER_UNDEFINED, 1); $righthookx_adjust = 8; } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); // Add hook for charm/stone below the name //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_width/2 + 2, $VAR_height*0.83 - 15); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_align == 'left') { if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 8, $hooklefty - 18); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last + 6, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_orig_width - $VAR_width_last - $text_width_adjust + $righthookx_adjust, $hookrighty - 15); } } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } } else { //align is center if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 6, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 18); } } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //With Image at bottom of text $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_center_bottom = new Imagick($img_center_bottom); $VAR_img_bottom_x = isset($layer['bottom_img_x']) ? $layer['bottom_img_x'] : 0; $VAR_img_bottom_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; $tmp_txt_Canvas->compositeImage($tmp_center_bottom, imagick::COMPOSITE_DEFAULT, $VAR_img_bottom_x, $VAR_img_bottom_y); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_align == 'left') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); } //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_align == 'left') { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_orig_width - $VAR_width_last + $VAR_chain_right_x - $text_width_adjust + $righthookx_adjust, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } // Make a Canvas with Skewed Image $tmp_txt_Canvas_f = new Imagick(); $tmp_txt_Canvas_f->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas_f->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, 0, -100); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); $tmp_center_bottom->clear(); $tmp_txt_Canvas->clear(); return array('txt_canvas' => $tmp_txt_Canvas_f); } //with end image, bottom image and transform function FUNC_name_text_new_3b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_max_text_width = isset($layer['max_text_width']) ? $layer['max_text_width'] : $core_width; // Text Canvas Width // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // Distortion Parameters $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } else if($VAR_fontname == "Cochin") { if($hookrighty < 15) { $hookrighty = 15; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else if($VAR_fontname == "Cochin") { if ($hookleftx < 20) { $hookleftx = 20; } } else { if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u" || $VAR_txt[$VAR_length-1] == "y") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { if($VAR_fontname == "Cochin") { $draw->setGravity(Imagick::GRAVITY_NORTH); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_ascender = $tmp_metrics['ascender']; /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); //$draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } //$draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas if($VAR_align == 'left') { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); } // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->newImage($VAR_orig_width + 30, $VAR_orig_height + 60, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("#fffcd2")); } else { $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); } } else { $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); } /* // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->newImage($VAR_width + $end_img_width + 30, $VAR_new_height + 60, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 60, new ImagickPixel("#fffcd2")); } else { $tmp_txt_Canvas->newImage($VAR_width + $end_img_width + 20, $VAR_new_height, new ImagickPixel("none")); } } else { $tmp_txt_Canvas->newImage($VAR_width + $end_img_width, $VAR_orig_height, new ImagickPixel("none")); } */ $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } //Resize text if exceed maximum width $text_canvas_width = $tmp_txt_Canvas->getImageWidth(); $text_canvas_height = $tmp_txt_Canvas->getImageHeight(); $text_width_adjust = 0; $righthookx_adjust = 0; //$VAR_xscale = 352/$VAR_orig_width; if($VAR_orig_width > $VAR_max_text_width) { $text_width_adjust = $VAR_orig_width - $VAR_max_text_width; //$tmp_txt_Canvas->resizeImage($text_canvas_width - $text_width_adjust, $VAR_new_height, imagick::FILTER_UNDEFINED, 1); $tmp_txt_Canvas->resizeImage($VAR_max_text_width, $VAR_orig_height, imagick::FILTER_UNDEFINED, 1); $righthookx_adjust = 8; $VAR_orig_width = $VAR_max_text_width; } // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_img_width = $tmp_end_img->getImageWidth(); $end_img_height = $tmp_end_img->getImageHeight(); // Create new canvas for text and end image $tmp_txt_Canvas->newImage($VAR_orig_width + $end_img_width + 20, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, 0); $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_orig_width - 5, $VAR_orig_ascender - $end_img_height); $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); // Add hook for charm/stone below the name //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_width/2 + 2, $VAR_height*0.83 - 15); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_align == 'left') { if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 8, $hooklefty - 18); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last + 6, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_orig_width + $end_img_width - 15, $VAR_orig_ascender - $end_img_height - 12); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_orig_width - $VAR_width_last - $text_width_adjust + $righthookx_adjust, $hookrighty - 15); } } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } } else { //align is center if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_fontname == "Cochin") { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 6, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 18); } } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //With Image at bottom of text $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_center_bottom); $VAR_img_bottom_x = isset($layer['bottom_img_x']) ? $layer['bottom_img_x'] : 0; $VAR_img_bottom_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; $bottom_img_width = $tmp_img_bottom->getImageWidth(); $tmp_txt_Canvas->compositeImage($tmp_img_bottom, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_orig_width + $end_img_width - $bottom_img_width - 5, $VAR_img_bottom_y); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_align == 'left') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); } //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of chain image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_align == 'left') { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_chain_right_x + $VAR_orig_width + $end_img_width - 15, $VAR_orig_ascender - $end_img_height - $chain_right_y + $VAR_chain_right_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_orig_width - $VAR_width_last + $VAR_chain_right_x - $text_width_adjust + $righthookx_adjust, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } // Make a Canvas with Skewed Image $tmp_txt_Canvas_f = new Imagick(); $tmp_txt_Canvas_f->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas_f->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, 0, -100); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); $tmp_img_bottom->clear(); $tmp_txt_Canvas->clear(); return array('txt_canvas' => $tmp_txt_Canvas_f); } // For Vertical Text Pendant function FUNC_name_text_new_4($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Vertical Text Pendant function FUNC_name_text_new_4b($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; if($VAR_txt[0] == "A") { $VAR_PL += 5; $VAR_PT -= 28; } else if($VAR_txt[0] == "B" || $VAR_txt[0] == "P") { $VAR_PT += 5; } else if($VAR_txt[0] == "C") { $VAR_PL += 10; } else if($VAR_txt[0] == "D") { $VAR_PT += 5; } else if($VAR_txt[0] == "E") { $VAR_PL += 10; $VAR_PT += 2; } else if($VAR_txt[0] == "F") { $VAR_PL -= 5; $VAR_PT += 2; } else if($VAR_txt[0] == "G") { $VAR_PL += 10; $VAR_PT -= 4; } else if($VAR_txt[0] == "H" || $VAR_txt[0] == "I" || $VAR_txt[0] == "J" || $VAR_txt[0] == "K") { $VAR_PT += 2; } else if($VAR_txt[0] == "L") { $VAR_PL += 5; $VAR_PT -= 15; } else if($VAR_txt[0] == "T") { $VAR_PL -= 15; } else if($VAR_txt[0] == "Z") { $VAR_PL -= 12; $VAR_PT -= 27; } //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx+30, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx+30, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Vertical Text Pendant - adjust for Wildera font function FUNC_name_text_new_4d($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; /*if($VAR_txt[0] == "A") { $VAR_PL += 5; $VAR_PT -= 28; } else if($VAR_txt[0] == "B" || $VAR_txt[0] == "P") { $VAR_PT += 5; } else if($VAR_txt[0] == "C") { $VAR_PL += 10; } else if($VAR_txt[0] == "D") { $VAR_PT += 5; } else if($VAR_txt[0] == "E") { $VAR_PL += 10; $VAR_PT += 2; } else if($VAR_txt[0] == "F") { $VAR_PL -= 5; $VAR_PT += 2; } else if($VAR_txt[0] == "G") { $VAR_PL += 10; $VAR_PT -= 4; } else if($VAR_txt[0] == "H" || $VAR_txt[0] == "I" || $VAR_txt[0] == "J" || $VAR_txt[0] == "K") { $VAR_PT += 2; } else if($VAR_txt[0] == "L") { $VAR_PL += 5; $VAR_PT -= 15; } else if($VAR_txt[0] == "T") { $VAR_PL -= 15; } else if($VAR_txt[0] == "Z") { $VAR_PL -= 12; $VAR_PT -= 27; }*/ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx+20, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx+20, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Vertical Text Pendant - adjust for Italliano font function FUNC_name_text_new_4c($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; if($VAR_txt[0] == "A") { $VAR_PL += 5; $VAR_PT -= 28; } else if($VAR_txt[0] == "B" || $VAR_txt[0] == "P") { $VAR_PT += 5; } else if($VAR_txt[0] == "C") { $VAR_PL += 10; } else if($VAR_txt[0] == "D") { $VAR_PT += 5; } else if($VAR_txt[0] == "E") { $VAR_PL += 10; $VAR_PT += 2; } else if($VAR_txt[0] == "F") { $VAR_PL -= 5; $VAR_PT += 2; } else if($VAR_txt[0] == "G") { $VAR_PL += 10; $VAR_PT -= 4; } else if($VAR_txt[0] == "H" || $VAR_txt[0] == "I" || $VAR_txt[0] == "J" || $VAR_txt[0] == "K") { $VAR_PT += 2; } else if($VAR_txt[0] == "L") { $VAR_PL += 5; $VAR_PT -= 15; } else if($VAR_txt[0] == "T") { $VAR_PL -= 15; } else if($VAR_txt[0] == "Z") { $VAR_PL -= 12; $VAR_PT -= 27; } //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx+20, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx+20, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_5($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of all character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_width_all = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get middle of text $hookx = $core_width/2; //get position of right hook for ($i = $VAR_width_all/2; $i <= $VAR_width_all; $i++) { for ($j = 0; $j <= $tmp_metrics['textHeight']; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $j); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookx = $i; $hooky = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height+4, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, ($VAR_width/2)-7, $hooky-22); } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text $f_tmp = pathinfo($layer['bottom_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Compute width of bottom image $bottom_image_width = $tmp_img_bottom->getImageWidth(); $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas //$tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2), $bottom_image_y + 15); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $VAR_PT; // Add hook height //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2, $VAR_PT_new + $bottom_image_y); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_height = $tmp_chain_left->getImageHeight(); $chain_left_y = $VAR_PT_new + $hooky - $chain_height - 5; $chain_width = $tmp_chain_left->getImageWidth(); //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $core_width/2 - $chain_width/2, $chain_left_y ); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); } // Clear canvasses $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); //$tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with no hook and bottom image function FUNC_name_text_new_6($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //Adjustment for text align center $VAR_center_adjust = 0; } else { $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height+4, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); } // Clear canvasses $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function iMagickColorToHEX($string) { $pixel = new ImagickPixel($string); $color = $pixel->getColor(); return sprintf('#%s%s%s', dechex($color['r']), dechex($color['g']), dechex($color['b']) ); } function FUNC_text_Vextical_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); /* // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; */ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_NORTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); $max_height = $VAR_height - 50; $prev_has_descender = false; $prev_descender = 0; //Get text height for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } $text_height = $h; //$text_height = $tmp_metrics['ascender'] * $textlength * $VAR_line_height; if($text_height > $max_height) { $VAR_size = $VAR_size * ($max_height / $text_height); //$VAR_size = round($max_height / $textlength); $draw->setFontSize($VAR_size); } /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } $draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //echo ''; /* for($i=0;$i< $textlength ;$i++) { $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['textHeight']) * $VAR_line_height; //$h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } //$h+=$tmp_metrics['ascender'] * $VAR_line_height; //$h+=$tmp_metrics['textHeight'] * $VAR_line_height; $draw->annotation(0, $h, substr($VAR_txt,$i,1)); //echo substr($VAR_txt,$i,1).'
'; //print_r($tmp_metrics); $text_height = $h; } */ //echo ''; //exit; /* echo ''; print_r($h); echo ''; exit; */ $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //New Y position of text $y_new = $VAR_PT + ((($VAR_PB - $VAR_PT) - $h) / 2); /* if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } */ if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Vextical_2($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); /* // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; */ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_NORTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); $max_height = $VAR_height - 50; $prev_has_descender = false; $prev_descender = 0; //Get text height for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } $text_height = $h; //$text_height = $tmp_metrics['ascender'] * $textlength * $VAR_line_height; if($text_height > $max_height) { $VAR_size = $VAR_size * ($max_height / $text_height); //$VAR_size = round($max_height / $textlength); $draw->setFontSize($VAR_size); } /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } $draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //echo ''; /* for($i=0;$i< $textlength ;$i++) { $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['textHeight']) * $VAR_line_height; //$h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } //$h+=$tmp_metrics['ascender'] * $VAR_line_height; //$h+=$tmp_metrics['textHeight'] * $VAR_line_height; $draw->annotation(0, $h, substr($VAR_txt,$i,1)); //echo substr($VAR_txt,$i,1).'
'; //print_r($tmp_metrics); $text_height = $h; } */ //echo ''; //exit; /* echo ''; print_r($h); echo ''; exit; */ $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //New Y position of text $y_new = $VAR_PT + ((($VAR_PB - $VAR_PT) - $h) / 2); /* if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } */ if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Vextical_3($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); /* // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; */ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_NORTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); $max_height = $VAR_height - 50; $prev_has_descender = false; $prev_descender = 0; //Get text height for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } $text_height = $h; //$text_height = $tmp_metrics['ascender'] * $textlength * $VAR_line_height; if($text_height > $max_height) { $VAR_size = $VAR_size * ($max_height / $text_height); //$VAR_size = round($max_height / $textlength); $draw->setFontSize($VAR_size); } /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Draw vertical text shadow start // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; $j=0; for ($j = 1; $j <= $shadow_depth; $j++) { $draw->annotation($sx, $h + $sy, substr($VAR_txt,$i,1)); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } //$draw->annotation($shadow_xoffset, $h + $shadow_yoffset, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text shadow end //Draw vertical text start // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = $text_xoffset; $ty = $text_yoffset; $j=0; for ($j = 1; $j <= $text_depth; $j++) { $draw->annotation($tx, $h + $ty, substr($VAR_txt,$i,1)); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text end //echo ''; /* for($i=0;$i< $textlength ;$i++) { $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['textHeight']) * $VAR_line_height; //$h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } //$h+=$tmp_metrics['ascender'] * $VAR_line_height; //$h+=$tmp_metrics['textHeight'] * $VAR_line_height; $draw->annotation(0, $h, substr($VAR_txt,$i,1)); //echo substr($VAR_txt,$i,1).'
'; //print_r($tmp_metrics); $text_height = $h; } */ //echo ''; //exit; /* echo ''; print_r($h); echo ''; exit; */ $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //New Y position of text $y_new = $VAR_PT + ((($VAR_PB - $VAR_PT) - $h) / 2); /* if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } */ if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Vextical_3a($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); /* // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; */ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_NORTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); $max_height = $VAR_height - 50; $prev_has_descender = false; $prev_descender = 0; //Get text height for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } $text_height = $h; //$text_height = $tmp_metrics['ascender'] * $textlength * $VAR_line_height; if($text_height > $max_height) { $VAR_size = $VAR_size * ($max_height / $text_height); //$VAR_size = round($max_height / $textlength); $draw->setFontSize($VAR_size); } /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Draw vertical text shadow start // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; $j=0; for ($j = 1; $j <= $shadow_depth; $j++) { $draw->annotation($sx, $h + $sy, substr($VAR_txt,$i,1)); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } //$draw->annotation($shadow_xoffset, $h + $shadow_yoffset, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text shadow end //Draw vertical text start // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = $text_xoffset; $ty = $text_yoffset; $j=0; for ($j = 1; $j <= $text_depth; $j++) { $draw->annotation($tx, $h + $ty, substr($VAR_txt,$i,1)); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text end //echo ''; /* for($i=0;$i< $textlength ;$i++) { $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['textHeight']) * $VAR_line_height; //$h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } //$h+=$tmp_metrics['ascender'] * $VAR_line_height; //$h+=$tmp_metrics['textHeight'] * $VAR_line_height; $draw->annotation(0, $h, substr($VAR_txt,$i,1)); //echo substr($VAR_txt,$i,1).'
'; //print_r($tmp_metrics); $text_height = $h; } */ //echo ''; //exit; /* echo ''; print_r($h); echo ''; exit; */ $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //New Y position of text $y_new = $VAR_PT + ((($VAR_PB - $VAR_PT) - $h) / 2); /* if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } */ if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } //Vertical text aligned to the bottom function FUNC_text_Vextical_4($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); /* // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; */ //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_NORTH); //$draw->setGravity(Imagick::GRAVITY_CENTER); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); $max_height = $VAR_height - 10; $prev_has_descender = false; $prev_descender = 0; //Get text height for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } $text_height = $h; //Starting position of text aligned to the bottom $y_new = $VAR_height - $h - 40; //$text_height = $tmp_metrics['ascender'] * $textlength * $VAR_line_height; if($text_height > $max_height) { $VAR_size = $VAR_size * ($max_height / $text_height); //$VAR_size = round($max_height / $textlength); $draw->setFontSize($VAR_size); $y_new = $VAR_height - ($h * ($max_height / $text_height)) - 40; } /* echo ''; print_r($VAR_size); echo ''; exit; */ //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Draw vertical text shadow start // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; $j=0; for ($j = 1; $j <= $shadow_depth; $j++) { $draw->annotation($sx, $y_new + $h + $sy, substr($VAR_txt,$i,1)); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } //$draw->annotation($shadow_xoffset, $h + $shadow_yoffset, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text shadow end //Draw vertical text start // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $h=0; $prev_has_descender = false; $prev_descender = 0; for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['boundingBox']['y2']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } if($prev_has_descender) { $h-=$prev_descender; } // Draw text shadow on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = $text_xoffset; $ty = $text_yoffset; $j=0; for ($j = 1; $j <= $text_depth; $j++) { $draw->annotation($tx, $y_new + $h + $ty, substr($VAR_txt,$i,1)); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, $h, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $prev_has_descender = true; $prev_descender = $tmp_metrics['boundingBox']['y1']; } else { $prev_has_descender = false; } } //Draw vertical text end //echo ''; /* for($i=0;$i< $textlength ;$i++) { $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); if($tmp_metrics['boundingBox']['y1'] < 0) { $h+=($tmp_metrics['textHeight']) * $VAR_line_height; //$h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } else { $h+=($tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']) * $VAR_line_height; } //$h+=$tmp_metrics['ascender'] * $VAR_line_height; //$h+=$tmp_metrics['textHeight'] * $VAR_line_height; $draw->annotation(0, $h, substr($VAR_txt,$i,1)); //echo substr($VAR_txt,$i,1).'
'; //print_r($tmp_metrics); $text_height = $h; } */ //echo ''; //exit; /* echo ''; print_r($h); echo ''; exit; */ //$tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("#fff1d7")); $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //New Y position of text //Text Aligned at Bottom Vertically //$y_new = $VAR_PT + $VAR_height - $h; //Text Aligned at Center Vertically //$y_new = $VAR_PT + ((($VAR_PB - $VAR_PT) - $h) / 2); /* if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), -90); } else { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 90); } */ if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$VAR_args= array(50); //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } //Horizontal Text with Decreasing Font size function FUNC_text_Size_Decreasing($layer) { global $PATH_components, $core_width, $core_height, $productid;; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width //$VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PB = isset($layer['bottom']) ? $layer['bottom'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_line_height = isset($layer['line_height']) ? $layer['line_height'] : 1; // Text Canvas right position $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Factor to multiply to decrease the font size (value less than 1) $fs_factor = isset($layer['size_factor']) ? $layer['size_factor'] : 0.8; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 1; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius if($VAR_args != 0) $VAR_args = explode("-", $VAR_args); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setGravity(Imagick::GRAVITY_WEST); // Get Font Metrics $tmp_metrics = ""; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $textlength= strlen($VAR_txt); //Get text width for($i=0;$i< $textlength ;$i++) { //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); $w+=($tmp_metrics['characterWidth']); //$h+=($tmp_metrics['boundingBox']['x2']); } $text_width = $w; if($textlength < 3) { $space_plus = 10; } else if($textlength == 3) { $space_plus = 8; } else if($textlength == 4) { $space_plus = 6; } else if($textlength == 5) { $space_plus = 4; } else if($textlength == 6) { $space_plus = 2; } else { $space_plus = 1; } /* echo ''; print_r($VAR_size); echo ''; exit; */ //Draw vertical text shadow start // Set color and alpha for text $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } $i=0; $w=0; $fs = $VAR_size; for($i=0;$i< $textlength ;$i++) { $draw->setFontSize($fs); //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); $w+=$tmp_metrics['boundingBox']['x1']; // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; $j=0; for ($j = 1; $j <= $shadow_depth; $j++) { $draw->annotation($sx + $w, $sy, substr($VAR_txt,$i,1)); //$draw->annotation($sx, $y_new + $h + $sy, substr($VAR_txt,$i,1)); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } if(substr($VAR_txt,$i,1) == "I") { $w+=$tmp_metrics['boundingBox']['x2'] + $space_plus + 3; } else { $w+=$tmp_metrics['boundingBox']['x2'] + $space_plus; } $fs *= $fs_factor; } //Draw vertical text shadow end //Draw vertical text start // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas //$draw->annotation(0, 0, $VAR_txt); $i=0; $w=0; $fs = $VAR_size; for($i=0;$i< $textlength ;$i++) { $draw->setFontSize($fs); //get fontmetrics of character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, substr($VAR_txt,$i,1)); $w+=$tmp_metrics['boundingBox']['x1']; //$h+=($tmp_metrics['characterWidth']); // Draw text shadow on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw shadow text $tx = $text_xoffset; $ty = $text_yoffset; $j=0; for ($j = 1; $j <= $text_depth; $j++) { $draw->annotation($tx + $w, $ty, substr($VAR_txt,$i,1)); //$draw->annotation($tx, $y_new + $h + $ty, substr($VAR_txt,$i,1)); $tx += $text_xoffset; $ty += $text_yoffset; } } if(substr($VAR_txt,$i,1) == "I") { $w+=$tmp_metrics['boundingBox']['x2'] + $space_plus + 3; } else { $w+=$tmp_metrics['boundingBox']['x2'] + $space_plus; } $fs *= $fs_factor; } //Draw vertical text end //$tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("#fff1d7")); $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($tmp_txt_Canvas->getImageWidth())*$VAR_xscale, ($tmp_txt_Canvas->getImageHeight())*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if((isset($VAR_skewx) && $VAR_skewx != 0) || (isset($VAR_skewy) && $VAR_skewy != 0)) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } //$tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 63); $tmp_Clone = clone $tmp_txt_Canvas; //$tmp_Clone = $tmp_txt_Canvas->clone(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_txt == "") { $f_tmp = pathinfo($layer['dots_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_dots = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_dots = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_dots_img = new Imagick($img_dots); $tmp_txt_Canvas->compositeImage($tmp_dots_img, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_dots_img->clear(); } else { //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $y_new); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); } return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving Multiline function FUNC_text_Line_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, 0); return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $left_offset, '_y' => $VAR_PT); } // Multiple Text Engraving on Circle function FUNC_text_Circle_1($layer, $textnum) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference // use text number in array $toparray = explode(',', $layer['top']); $VAR_PT = $toparray[$textnum]; $leftarray = explode(',', $layer['left']); $VAR_PL = $leftarray[$textnum]; //$VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position //$VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc // use text number in array $arcarray = explode(',', $layer['arc_args']); $VAR_args = $arcarray[$textnum]; //$VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { if($layer['font'] == 'Cochin') { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 70, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } } else { if($layer['font'] == 'Cochin') { $tmp_txt_Canvas->newImage($VAR_width + 30, $VAR_new_height + 70, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values if($layer['font'] == 'Cochin') { $tmp_txt_Canvas->resizeImage(($VAR_width+30)*$VAR_xscale, ($VAR_height+30)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); } else { $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); } //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, 0); return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $left_offset, '_y' => $VAR_PT); } function FUNC_2_text_stone($layer) { global $PATH_components, $core_width, $core_height, $productid;; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : $core_height; $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; $VAR_text_offset = isset($layer['text_offset']) ? $layer['text_offset'] : 0; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas //$VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas //$VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + 30; $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $VAR_orig_height = $VAR_txt_height; $top_offset = 0; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if($VAR_txt_width > $VAR_width) { $VAR_size = floor($VAR_size * ($VAR_width / $VAR_txt_width)); $VAR_kern = floor($VAR_kern * ($VAR_width / $VAR_txt_width)); $draw->setFontSize($VAR_size); $draw->setTextKerning($VAR_kern); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); $tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + 30; $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $top_offset = (($VAR_orig_height - $VAR_txt_height)) / 2 - 1; } } // Draw first text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt_1); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw first text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt_1); $tx += $text_xoffset; $ty += $text_yoffset; } } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); // Draw second text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $tmp_metrics['U']['textWidth'] + $shadow_xoffset + 30; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt_2); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw second text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = $tmp_metrics['U']['textWidth'] + 32; } else { $tx = $tmp_metrics['U']['textWidth'] + 30; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt_2); $tx += $text_xoffset; $ty += $text_yoffset; } } $tmp_txt_Canvas->newImage($VAR_txt_width + 10, $VAR_txt_height + 10, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //append stone image to end of text 1 $f_tmp = pathinfo($layer['stone_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_stone = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_stone = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_stone = new Imagick($img_stone); $img_stone_x = (30 - $tmp_stone->getImageWidth()) / 2; $img_stone_y = ($VAR_txt_height - $tmp_stone->getImageHeight() - 4) / 2; $tmp_txt_Canvas->compositeImage($tmp_stone, imagick::COMPOSITE_DEFAULT, $tmp_metrics['U']['textWidth'] + $img_stone_x, $img_stone_y); $tmp_stone->clear(); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_txt_width + 10)*$VAR_xscale, ($VAR_txt_height + 10)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if($VAR_align == "center"){ $left_offset = ($VAR_width - $VAR_txt_width + 10) / 2; //$left_offset = $VAR_PL + ($core_width - $VAR_txt_width - $VAR_PL - $VAR_PR) / 2; }elseif($VAR_align == "right"){ $left_offset = $VAR_width; } else { $left_offset = 0; } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($VAR_width, $VAR_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $left_offset, $top_offset); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, 0); if(isset($tmp_Clone)) $tmp_Clone->destroy(); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } // Monogram Text Engraving New function FUNC_text_monogram_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Split Text $arr_str = str_split($VAR_txt); // split text //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); /* echo ''; print_r($tmp_metrics); echo ''; exit; */ $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } if ( strlen($VAR_txt) == 3 ){ for ($j = 0; $j < count($arr_str); $j++) { if($j == 1) { $draw->setFontSize($VAR_size); } else { $draw->setFontSize($VAR_size*0.8); } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text if($j == 0) { $sx = $shadow_xoffset - ($VAR_size*0.48); $sy = $shadow_yoffset + ($VAR_size*0.058); } else if($j == 2) { $sx = $shadow_xoffset + ($VAR_size*0.48); $sy = $shadow_yoffset + ($VAR_size*0.058); } else { $sx = $shadow_xoffset; $sy = $shadow_yoffset; } for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; if($j == 0) { $tx -= ($VAR_size*0.48); $ty += ($VAR_size*0.058); } else if($j == 2) { $tx += ($VAR_size*0.48); $ty += ($VAR_size*0.058); } for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } } else { // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } } $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text Engraving New function FUNC_text_monogram_1a($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Split Text $arr_str = str_split($VAR_txt); // split text //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); /* echo ''; print_r($tmp_metrics); echo ''; exit; */ $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } if ( strlen($VAR_txt) == 3 ){ $x_adjust1 = 0.5; $x_adjust3 = 0.5; $y_adjust1 = 0.02; $y_adjust2 = 0; $y_adjust3 = 0.02; for ($j = 0; $j < count($arr_str); $j++) { if($j == 0) { if ($VAR_txt[$j] == "A") { $x_adjust1 = 0.45; $y_adjust1 = 0.04; } else if ($VAR_txt[$j] == "C") { $y_adjust1 = 0.03; } else if ($VAR_txt[$j] == "D" || $VAR_txt[$j] == "M") { $x_adjust1 = 0.6; } else if ($VAR_txt[$j] == "G") { $y_adjust1 = 0.07; } else if ($VAR_txt[$j] == "I") { $x_adjust1 = 0.45; } else if ($VAR_txt[$j] == "J") { $x_adjust1 = 0.4; $y_adjust1 = 0.04; } else if ($VAR_txt[$j] == "K") { $y_adjust1 = 0.04; } else if ($VAR_txt[$j] == "Q") { $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "R") { $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "S") { $x_adjust1 = 0.45; $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "U" || $VAR_txt[$j] == "V") { $x_adjust1 = 0.55; $y_adjust1 = -0.02; } else if ($VAR_txt[$j] == "W") { $x_adjust1 = 0.65; $y_adjust1 = -0.02; } else if ($VAR_txt[$j] == "Y") { $y_adjust1 = -0.01; } else { $x_adjust1 = 0.5; $y_adjust1 = 0.02; } } else if($j == 2) { if ($VAR_txt[$j] == "A" || $VAR_txt[$j] == "O") { $x_adjust3 = 0.55; } else if ($VAR_txt[$j] == "C") { $y_adjust3 = 0.03; } else if ($VAR_txt[$j] == "D" || $VAR_txt[$j] == "H" || $VAR_txt[$j] == "M" || $VAR_txt[$j] == "N") { $x_adjust3 = 0.6; } else if ($VAR_txt[$j] == "G") { $y_adjust3 = 0.05; } else if ($VAR_txt[$j] == "K") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "Q") { $x_adjust3 = 0.6; $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "R") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "T") { $y_adjust3 = -0.01; } else if ($VAR_txt[$j] == "U" || $VAR_txt[$j] == "V") { $x_adjust3 = 0.55; $y_adjust3 = -0.02; } else if ($VAR_txt[$j] == "W") { $x_adjust3 = 0.65; $y_adjust3 = -0.02; } else if ($VAR_txt[$j] == "Y") { $y_adjust3 = -0.02; } else { $x_adjust3 = 0.5; $y_adjust3 = 0.02; } } else { if ($VAR_txt[$j] == "A") { $y_adjust2 = 0.03; } else if ($VAR_txt[$j] == "C" || $VAR_txt[$j] == "S") { $y_adjust2 = 0.05; } else if ($VAR_txt[$j] == "G") { $y_adjust2 = 0.07; } else if ($VAR_txt[$j] == "J" || $VAR_txt[$j] == "K" || $VAR_txt[$j] == "R") { $y_adjust2 = 0.06; } else if ($VAR_txt[$j] == "T" || $VAR_txt[$j] == "U") { $y_adjust2 = -0.04; } else if ($VAR_txt[$j] == "V" || $VAR_txt[$j] == "W" || $VAR_txt[$j] == "Y") { $y_adjust2 = -0.03; } else { $y_adjust2 = 0; } } if($j == 1) { $draw->setFontSize($VAR_size); } else { $draw->setFontSize($VAR_size*0.65); } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text if($j == 0) { $sx = $shadow_xoffset - ($VAR_size*$x_adjust1); //$sx = $shadow_xoffset - ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust1); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else if($j == 2) { $sx = $shadow_xoffset + ($VAR_size*$x_adjust3); //$sx = $shadow_xoffset + ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust3); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else { $sx = $shadow_xoffset; $sy = $shadow_yoffset - ($VAR_size*$y_adjust2); } for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; if($j == 0) { $tx -= ($VAR_size*$x_adjust1); //$tx -= ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust1); //$ty += ($VAR_size*0.058); } else if($j == 2) { $tx += ($VAR_size*$x_adjust3); //$tx += ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust3); //$ty += ($VAR_size*0.058); } else { $ty -= ($VAR_size*$y_adjust2); } for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } } else { if ( strlen($VAR_txt) == 2 ){ $VAR_size = $VAR_size * 0.8; $draw->setFontSize($VAR_size); } $y_adjust = 0; for ($j = 0; $j < count($arr_str); $j++) { if ($VAR_txt[$j] == "A") { $y_adjust = 0.03; } else if ($VAR_txt[$j] == "C" || $VAR_txt[$j] == "S") { $y_adjust = 0.05; } else if ($VAR_txt[$j] == "G") { $y_adjust = 0.07; } else if ($VAR_txt[$j] == "J" || $VAR_txt[$j] == "K" || $VAR_txt[$j] == "R") { $y_adjust = 0.06; } else if ($VAR_txt[$j] == "T" || $VAR_txt[$j] == "U") { $y_adjust = -0.04; } else if ($VAR_txt[$j] == "V" || $VAR_txt[$j] == "W" || $VAR_txt[$j] == "Y") { $y_adjust = -0.03; } else { $y_adjust = 0; } } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset - ($VAR_size*$y_adjust); //$sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; $ty -= ($VAR_size*$y_adjust); for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } } $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text Engraving New function FUNC_text_monogram_1b($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Split Text $arr_str = str_split($VAR_txt); // split text //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); /* echo ''; print_r($tmp_metrics); echo ''; exit; */ $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } if ( strlen($VAR_txt) == 3 ){ $x_adjust1 = 0.4; $x_adjust3 = 0.4; $y_adjust1 = 0; $y_adjust2 = 0; $y_adjust3 = 0; /* $x_adjust1 = 0.5; $x_adjust3 = 0.5; $y_adjust1 = 0.02; $y_adjust2 = 0; $y_adjust3 = 0.02; */ // Get Font Metrics of middle letter $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $textwidth1 = $tmp_metrics['textWidth']; $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[1]); $textwidth2 = $tmp_metrics['textWidth']; $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[2]); $textwidth3 = $tmp_metrics['textWidth']; for ($j = 0; $j < count($arr_str); $j++) { if($j == 0) { if ($VAR_txt[$j] == "A") { $x_adjust1 = 0.3; $y_adjust1 = 0.03; } else if ($VAR_txt[$j] == "C") { $y_adjust1 = 0.03; } else if ($VAR_txt[$j] == "D" || $VAR_txt[$j] == "M" || $VAR_txt[$j] == "O") { $x_adjust1 = 0.45; } else if ($VAR_txt[$j] == "G") { $y_adjust1 = 0.06; } else if ($VAR_txt[$j] == "H" || $VAR_txt[$j] == "X") { $x_adjust1 = 0.3; } else if ($VAR_txt[$j] == "I") { $x_adjust1 = 0.45; } else if ($VAR_txt[$j] == "J") { $y_adjust1 = 0.04; } else if ($VAR_txt[$j] == "K") { $y_adjust1 = 0.04; } else if ($VAR_txt[$j] == "Q") { $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "R") { $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "S") { //$x_adjust1 = 0.45; $y_adjust1 = 0.02; } else if ($VAR_txt[$j] == "U" || $VAR_txt[$j] == "V") { $x_adjust1 = 0.45; $y_adjust1 = -0.02; } else if ($VAR_txt[$j] == "W") { $x_adjust1 = 0.45; $y_adjust1 = -0.02; } else if ($VAR_txt[$j] == "Y") { $y_adjust1 = -0.01; } else { $x_adjust1 = 0.4; $y_adjust1 = 0; } } else if($j == 2) { if ($VAR_txt[$j] == "A") { $x_adjust3 = 0.3; } else if ($VAR_txt[$j] == "C") { $y_adjust3 = 0.03; } else if ($VAR_txt[$j] == "D" || $VAR_txt[$j] == "M" || $VAR_txt[$j] == "N" || $VAR_txt[$j] == "O" || $VAR_txt[$j] == "S") { $x_adjust3 = 0.45; } else if ($VAR_txt[$j] == "G") { $y_adjust3 = 0.05; } else if ($VAR_txt[$j] == "I") { $x_adjust3 = 0.45; } else if ($VAR_txt[$j] == "J") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "K") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "Q") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "R") { $y_adjust3 = 0.04; } else if ($VAR_txt[$j] == "T") { $y_adjust3 = -0.01; } else if ($VAR_txt[$j] == "U" || $VAR_txt[$j] == "V") { $x_adjust3 = 0.45; $y_adjust3 = -0.02; } else if ($VAR_txt[$j] == "W") { $x_adjust3 = 0.45; $y_adjust3 = -0.02; } else if ($VAR_txt[$j] == "Y") { $y_adjust3 = -0.02; } else { $x_adjust3 = 0.4; $y_adjust3 = 0.0; } } else { if ($VAR_txt[$j] == "A") { $y_adjust2 = 0.03; } else if ($VAR_txt[$j] == "C" || $VAR_txt[$j] == "S") { $y_adjust2 = 0.04; } else if ($VAR_txt[$j] == "G") { $y_adjust2 = 0.07; } else if ($VAR_txt[$j] == "J" || $VAR_txt[$j] == "K" || $VAR_txt[$j] == "R") { $y_adjust2 = 0.06; } else if ($VAR_txt[$j] == "T" || $VAR_txt[$j] == "U") { $y_adjust2 = -0.04; } else if ($VAR_txt[$j] == "V" || $VAR_txt[$j] == "W" || $VAR_txt[$j] == "Y") { $y_adjust2 = -0.03; } else { $y_adjust2 = 0; } } if($j == 1) { $draw->setFontSize($VAR_size); } else { $draw->setFontSize($VAR_size*0.5); } /* if($j == 1) { $draw->setFontSize($VAR_size); } else { $draw->setFontSize($VAR_size*0.65); } */ // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text if($j == 0) { $sx = $shadow_xoffset - (($textwidth2 - $textwidth1*$x_adjust1)/2 + ($textwidth1*$x_adjust1)); //$sx = $shadow_xoffset - ($textwidth1*$x_adjust1); //$sx = $shadow_xoffset - ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust1); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else if($j == 2) { $sx = $shadow_xoffset + (($textwidth2 - $textwidth3*$x_adjust3)/2 + ($textwidth3*$x_adjust3)); //$sx = $shadow_xoffset + ($textwidth2*$x_adjust3); //$sx = $shadow_xoffset + ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust3); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else { $sx = $shadow_xoffset; $sy = $shadow_yoffset - ($VAR_size*$y_adjust2); } /* // Draw shadow text if($j == 0) { $sx = $shadow_xoffset - ($VAR_size*$x_adjust1); //$sx = $shadow_xoffset - ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust1); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else if($j == 2) { $sx = $shadow_xoffset + ($VAR_size*$x_adjust3); //$sx = $shadow_xoffset + ($VAR_size*0.48); $sy = $shadow_yoffset - ($VAR_size*$y_adjust3); //$sy = $shadow_yoffset + ($VAR_size*0.058); } else { $sx = $shadow_xoffset; $sy = $shadow_yoffset - ($VAR_size*$y_adjust2); } */ for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; if($j == 0) { $tx -= (($textwidth2 - $textwidth1*$x_adjust1)/2 + ($textwidth1*$x_adjust1)); //$tx -= ($textwidth1*$x_adjust1); //$tx -= ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust1); //$ty += ($VAR_size*0.058); } else if($j == 2) { $tx += (($textwidth2 - $textwidth3*$x_adjust3)/2 + ($textwidth3*$x_adjust3)); //$tx += ($textwidth2*$x_adjust3); //$tx += ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust3); //$ty += ($VAR_size*0.058); } else { $ty -= ($VAR_size*$y_adjust2); } /* if($j == 0) { $tx -= ($VAR_size*$x_adjust1); //$tx -= ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust1); //$ty += ($VAR_size*0.058); } else if($j == 2) { $tx += ($VAR_size*$x_adjust3); //$tx += ($VAR_size*0.48); $ty -= ($VAR_size*$y_adjust3); //$ty += ($VAR_size*0.058); } else { $ty -= ($VAR_size*$y_adjust2); } */ for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } } else { if ( strlen($VAR_txt) == 2 ){ $VAR_size = $VAR_size * 0.8; $draw->setFontSize($VAR_size); } $y_adjust = 0; for ($j = 0; $j < count($arr_str); $j++) { if ($VAR_txt[$j] == "A") { $y_adjust = 0.03; } else if ($VAR_txt[$j] == "S") { $y_adjust = 0.04; } else if ($VAR_txt[$j] == "C") { $y_adjust = 0.05; } else if ($VAR_txt[$j] == "G" || $VAR_txt[$j] == "Q" || $VAR_txt[$j] == "R") { $y_adjust = 0.07; } else if ($VAR_txt[$j] == "J" || $VAR_txt[$j] == "K") { $y_adjust = 0.06; } else if ($VAR_txt[$j] == "T" || $VAR_txt[$j] == "U") { $y_adjust = -0.04; } else if ($VAR_txt[$j] == "V" || $VAR_txt[$j] == "W" || $VAR_txt[$j] == "Y") { $y_adjust = -0.03; } else { $y_adjust = 0; } } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset - ($VAR_size*$y_adjust); //$sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; $ty -= ($VAR_size*$y_adjust); for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } } $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Engraving - Pendant or Bracelet function FUNC_text_monogram_2_temp($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; /* if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } */ //$VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PT = $VAR_PT + (5 * ($VAR_size / 160)); if($VAR_size <= 64) { $VAR_PL = $VAR_PL + (5 * ($VAR_size / 64)); } else if($VAR_size > 64 && $VAR_size <= 80) { $VAR_PL = $VAR_PL - (5 * ($VAR_size / 80)); } else if($VAR_size >= 150) { $VAR_PL = $VAR_PL - (50 * ($VAR_size / 160)); } else { $VAR_PL = $VAR_PL - (25 * ($VAR_size / 120)); } $scale_h = -12; //$draw->setStrokeWidth(2); //$shad->setStrokeWidth(2); }else if($layer['font'] == "Heart") { $VAR_txt = " ".strtoupper($VAR_txt)." "; $VAR_font = $PATH_components.'fonts/'."heart.ttf"; $VAR_PT = $VAR_PT - (4 * ($VAR_size / 150)); //$VAR_PT = $VAR_PT - (6 * ($VAR_size / 150)); if($VAR_size <= 100) { $VAR_PL = $VAR_PL - (122 * ($VAR_size / 135)); } else if($VAR_size >= 136) { $VAR_PL = $VAR_PL - (122 * ($VAR_size / 150)); } else { $VAR_PL = $VAR_PL - (122 * ($VAR_size / 140)); } //$VAR_PL = $VAR_PL - (132 * ($VAR_size / 150)); $scale_w = 50; //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); }else if($layer['font'] == "Oval") { $str_a = strtoupper($VAR_txt); $VAR_txt = $str_a ; $VAR_font = $PATH_components.'fonts/'."oval_3.ttf"; $VAR_PT = $VAR_PT + 6; if($VAR_size <= 128) { $VAR_PL = $VAR_PL - (82 * ($VAR_size / 128)); } else if($VAR_size >= 190) { $VAR_PL = $VAR_PL - (94 * ($VAR_size / 164)); } else { $VAR_PL = $VAR_PL - (98 * ($VAR_size / 164)); } $scale_w = 50; $scale_h = -10; //$draw->setStrokeWidth(2); //$shad->setStrokeWidth(2); } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; $VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); }else if($layer['font'] == "Heart") { $VAR_font = $PATH_components.'fonts/'."heart_2.ttf"; $VAR_PL = $VAR_PL - (101 * ($VAR_size / 150)); }else if($layer['font'] == "Oval") { $VAR_font = $PATH_components.'fonts/'."oval_2.ttf"; $VAR_PL = $VAR_PL - (16 * ($VAR_size / 164)); //$VAR_PL = $VAR_PL + 5; } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$zsetFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to adjust spacing of characters if($VAR_kern != 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); /* echo ' '; print_r($tmp_metrics); echo ''; exit; */ $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } /* if ( strlen($VAR_txt) == 3 ){ for ($j = 0; $j < count($arr_str); $j++) { if($j == 1) { $draw->setFontSize($VAR_size); } else { $draw->setFontSize($VAR_size*0.8); } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text if($j == 0) { $sx = $shadow_xoffset - ($VAR_size*0.48); $sy = $shadow_yoffset + ($VAR_size*0.058); } else if($j == 2) { $sx = $shadow_xoffset + ($VAR_size*0.48); $sy = $shadow_yoffset + ($VAR_size*0.058); } else { $sx = $shadow_xoffset; $sy = $shadow_yoffset; } for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; if($j == 0) { $tx -= ($VAR_size*0.48); $ty += ($VAR_size*0.058); } else if($j == 2) { $tx += ($VAR_size*0.48); $ty += ($VAR_size*0.058); } for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } } else { */ // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //} $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_ring_1($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_width = $tmp_metrics['textWidth']; $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values //$tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } //if($VAR_args != 0) //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(80,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Cover for base ring image //Manual adjustment on first character of text to adjust size and position $first_char_set1 = array("B","C","E","G","H","K","O","Q","S","Y"); $first_char_set2 = array("D","F","I","P","R","U","Z"); if (in_array($VAR_txt[0], $first_char_set1)) { $cover_minus = 50; $cover_plus = 30; } else if (in_array($VAR_txt[0], $first_char_set2)) { $cover_minus = 70; $cover_plus = 45; } else if($VAR_txt[0] == "N") { $cover_minus = 50; $cover_plus = 40; } else if($VAR_txt[0] == "T") { $cover_minus = 100; $cover_plus = 80; } else if($VAR_txt[0] == "W") { $cover_minus = 40; $cover_plus = 20; } else { $cover_minus = 90; $cover_plus = 70; } $cover_top = 40; $tmp_txt_Cover = new Imagick(); $tmp_txt_Cover->newImage($VAR_new_width - $cover_minus, $VAR_new_height, new ImagickPixel("white")); $tmp_txt_Canvas->compositeImage($tmp_txt_Cover, imagick::COMPOSITE_DEFAULT, $VAR_PL+($VAR_width/2)-($VAR_new_width/2) + $cover_plus, $VAR_PT + $cover_top); $tmp_txt_Cover->clear(); //Create Embossed Effect for Name $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+9); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+7); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-3); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); } else { //Cover for base ring image //Manual adjustment on first character of text to adjust size and position $first_char_set1 = array("B","G","H"); $first_char_set2 = array("O","Q","W"); $first_char_no_cover = array("C","E","F","I","J","K","L","P","R","S","T","X","Z"); if (!in_array($VAR_txt[0], $first_char_no_cover)) { if (in_array($VAR_txt[0], $first_char_set1)) { $cover_minus = 50; $cover_plus = 30; } else if (in_array($VAR_txt[0], $first_char_set2)) { $cover_minus = 20; $cover_plus = 20; } else if($VAR_txt[0] == "D") { $cover_minus = 50; $cover_plus = 45; } else if($VAR_txt[0] == "M") { $cover_minus = 80; $cover_plus = 60; } else if($VAR_txt[0] == "N" || $VAR_txt[0] == "U") { $cover_minus = 50; $cover_plus = 40; } else if( $VAR_txt[0] == "Y") { $cover_minus = 20; $cover_plus = 17; } else if($VAR_txt[0] == "V") { $cover_minus = 50; $cover_plus = 50; } else { $cover_minus = 90; $cover_plus = 70; } $cover_top = 40; $tmp_txt_Cover = new Imagick(); $tmp_txt_Cover->newImage($VAR_new_width - $cover_minus, $VAR_new_height, new ImagickPixel("white")); $tmp_txt_Canvas->compositeImage($tmp_txt_Cover, imagick::COMPOSITE_DEFAULT, $VAR_PL+($VAR_width/2)-($VAR_new_width/2) + $cover_plus, $VAR_PT + $cover_top); $tmp_txt_Cover->clear(); } //Create Embossed Effect for Name $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+9); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+7); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-3); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // For Multiple One-Letter Pendant function FUNC_name_text_new_7($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text $arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //Base Image $f_tmp = pathinfo($layer['base_img']); // Path of Base Image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // For Multiple One-Letter Pendant with Rotation and without Base Images function FUNC_name_text_new_7a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text $arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("#faf2b0")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 20, new ImagickPixel("none")); } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); $r_arr = explode(",", $layer['r'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; ${"r$i"} = $r_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; $r = ${"r$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $tmp_txt_Canvas->annotateImage($draw, $sx, $sy, $r, $arr_str[$j]); //$draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; $r = ${"r$j"}; for ($i = 1; $i <= $text_depth; $i++) { $tmp_txt_Canvas->annotateImage($draw, $tx, $ty, $r, $arr_str[$j]); //$draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); //$tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } /* //Base Image $f_tmp = pathinfo($layer['base_img']); // Path of Base Image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); */ $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //$tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Name Jewelry - Text with End Image function FUNC_name_text_new_8($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_image_width = $tmp_end_img->getImageWidth(); $end_image_height = $tmp_end_img->getImageHeight(); if($endimg_resize) { $tmp_end_img->resizeImage($end_image_width*0.9, $end_image_height*0.9, Imagick::FILTER_LANCZOS, 1); } //Getting Position of Hook by detecting edge of Character //if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Height of 1st character as reference for y position of right hook $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_height_ref = $tmp_metrics['ascender']; $hookrighty = $VAR_height_ref - $end_image_height - 10; /* echo ''; echo "hookrighty: ".$hookrighty."'; exit; */ // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook //for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $j; break; } } //} $draw->clear(); $tmp_txt_Canvas->clear(); /* // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); */ // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook //$hookrightx += 25; //$hookrighty = 35; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $hookrighty; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); /* } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } */ // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); /* // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "l") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "s") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 78; } */ // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } //if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 2, $hooklefty - 10); /*} else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /* if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_center_adjust + $end_image_width - 15, $hookrighty - 15); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 115, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } */ // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // Create new canvas for End image $tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("none")); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, $VAR_height_difference); // Merge End image to canvas //if($VAR_length > 3) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 21, 20); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + 2, $hookrighty - 14); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 24); } //} // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); //if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_width = $tmp_chain_left->getImageWidth(); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + 24, $hooklefty - $chain_left_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width -15, $hookrighty*$hook_adjust_factor - $chain_right_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 115, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } /*} else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } */ // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); //$tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Name Jewelry - Text with End Image with Hook function FUNC_name_text_new_8a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -6; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_image_width = $tmp_end_img->getImageWidth(); $end_image_height = $tmp_end_img->getImageHeight(); if($endimg_resize) { $tmp_end_img->resizeImage($end_image_width*0.9, $end_image_height*0.9, Imagick::FILTER_LANCZOS, 1); } //Getting Position of Hook by detecting edge of Character //if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Height of 1st character as reference for y position of right hook //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); //$VAR_height_ref = $tmp_metrics['ascender']; //$hookrighty = 0; //$hookrighty = $VAR_height_ref - $end_image_height - 10; // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; //$tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); //$VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); //$draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 40; $i <= $tmp_metrics['textHeight']; $i++) { /* //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} */ for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); //$draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_size, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } //if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 2, $hooklefty - 40); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 2, $hooklefty - 10); /*} else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /* if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_center_adjust + $end_image_width - 15, $hookrighty - 15); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 115, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } */ // Clear Hook Canvas //$tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // Create new canvas for End image $tmp_txt_Canvas->newImage($VAR_width + 60, $end_image_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("#d6ebf2")); //$tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("none")); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, 28); //$tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, $VAR_height_difference); $tmp_end_img->resizeImage($tmp_metrics['textWidth']*0.8, $end_image_height, Imagick::FILTER_LANCZOS, 1); $end_image_width = $tmp_end_img->getImageWidth(); // Merge End image to canvas //if($VAR_length > 3) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - $end_image_width + 40, 0); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 21, 20); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - $end_image_width + 32, 0); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 207, 0); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + 2, $hookrighty - 14); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 24); } //} $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 10, 3); // Clear Hook Canvas $tmp_hook->clear(); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image //$tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("#e2d1e4")); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); //if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_width = $tmp_chain_left->getImageWidth(); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + 4, $hooklefty - $chain_left_y + 2); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT - $VAR_height_difference; $hookrighty = 12; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 25, $hookrighty*$hook_adjust_factor - $chain_right_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width -15, $hookrighty*$hook_adjust_factor - $chain_right_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 115, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } /*} else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } */ // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); //$tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Name Jewelry - Text with End Image with Adjustments for Fonts function FUNC_name_text_new_8b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_image_width = $tmp_end_img->getImageWidth(); $end_image_height = $tmp_end_img->getImageHeight(); if($endimg_resize) { $tmp_end_img->resizeImage($end_image_width*0.9, $end_image_height*0.9, Imagick::FILTER_LANCZOS, 1); } //Getting Position of Hook by detecting edge of Character //if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Height of 1st character as reference for y position of right hook $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_height_ref = $tmp_metrics['ascender']; if($layer['font'] == "Brush Script Std") { $hookrighty = $VAR_height_ref - $end_image_height + 27; } else { $hookrighty = $VAR_height_ref - $end_image_height - 10; } /* echo '
"; echo "VAR_height_ref: ".$VAR_height_ref."
"; echo "end_image_height: ".$end_image_height; echo ''; echo "hookrighty: ".$hookrighty."'; exit; */ // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook //for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $j; break; } } //} $draw->clear(); $tmp_txt_Canvas->clear(); /* // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); */ // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook //$hookrightx += 25; //$hookrighty = 35; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $hookrighty; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); /* } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } */ // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); /* // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "l") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "s") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 78; } */ // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("#fdf9c8")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } //if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 8); /*} else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /* if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_center_adjust + $end_image_width - 15, $hookrighty - 15); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 115, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } */ // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // Create new canvas for End image $tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("none")); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, $VAR_height_difference); // Merge End image to canvas //if($VAR_length > 3) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 21, 20); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + 2, $hookrighty - 14); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 24); } //} // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); //if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_width = $tmp_chain_left->getImageWidth(); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + $VAR_PL + 22, $hooklefty - $chain_left_y + 4); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width + $VAR_PL - 10, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 115, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + $VAR_PL + 18, $hookrighty*$hook_adjust_factor - 56); } /*} else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } */ // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); //$tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Name Jewelry - Text with End Image with Adjustments for Fonts function FUNC_name_text_new_8c($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_image_width = $tmp_end_img->getImageWidth(); $end_image_height = $tmp_end_img->getImageHeight(); if($endimg_resize) { $tmp_end_img->resizeImage($end_image_width*0.9, $end_image_height*0.9, Imagick::FILTER_LANCZOS, 1); } //Getting Position of Hook by detecting edge of Character //if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Height of 1st character as reference for y position of right hook $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_height_ref = $tmp_metrics['ascender']; if($layer['font'] == "Brush Script Std") { $hookrighty = $VAR_height_ref - $end_image_height + 27; } else if($layer['font'] == "Arial") { $hookrighty = $VAR_height_ref - $end_image_height + 17; } else { $hookrighty = $VAR_height_ref - $end_image_height - 10; } /* echo '
"; echo "VAR_height_ref: ".$VAR_height_ref."
"; echo "end_image_height: ".$end_image_height; echo ''; echo "hookrighty: ".$hookrighty."'; exit; */ // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook //for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $j; break; } } //} $draw->clear(); $tmp_txt_Canvas->clear(); /* // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); */ // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook //$hookrightx += 25; //$hookrighty = 35; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $hookrighty; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); /* } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } */ // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); /* // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "l") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "s") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 78; } */ // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("#fdf9c8")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } //if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 2, $hooklefty - 14); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 8); /*} else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /* if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_center_adjust + $end_image_width - 15, $hookrighty - 15); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 115, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } */ // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // Create new canvas for End image //$tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("#f2dbd2")); $tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("none")); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, $VAR_height_difference); // Merge End image to canvas //if($VAR_length > 3) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust, 21); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 21, 20); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + 2, $hookrighty - 14); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 24); } //} // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); //if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_width = $tmp_chain_left->getImageWidth(); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + $VAR_PL + 21, $hooklefty - $chain_left_y + 1); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + $VAR_PL + 22, $hooklefty - $chain_left_y + 4); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width + $VAR_PL - 12, $hookrighty*$hook_adjust_factor - $chain_right_y + 2); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width + $VAR_PL - 10, $hookrighty*$hook_adjust_factor - $chain_right_y); } //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width + $VAR_PL - 10, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 115, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + $VAR_PL + 18, $hookrighty*$hook_adjust_factor - 56); } /*} else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } */ // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); //$tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_9($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_image']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Bottom additional image $f_tmp = pathinfo($layer['bottom_image_add']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom_add = new Imagick($img_bottom_add); //Compute width of bottom image //$center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = $tmp_metrics['textWidth']; $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_img_bottom_add->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2) + 10, $bottom_image_y); /* //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new+13); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new+12); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+11); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+10); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new+9); //$tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - 20, $VAR_PT_new + $bottom_image_y + 2); //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 1); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 1); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 51); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); $tmp_img_bottom_add->clear(); $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_10($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $firstchar_color = isset($layer['firstcolor']) ? $layer['firstcolor'] : "black"; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); */ // Set color and alpha for text $draw->setFillColor($firstchar_color); //$tmp_metrics2 = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); //$draw->annotation(1-($tmp_metrics['textWidth']/2 - $tmp_metrics2['textWidth']/2), 0, $VAR_txt[0]); $tmp_txt_Canvas->drawImage($draw); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_image']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Bottom additional image $f_tmp = pathinfo($layer['bottom_image_add']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom_add = new Imagick($img_bottom_add); //Compute width of bottom image //$center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = $tmp_metrics['textWidth'] + 10; $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_img_bottom_add->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $bottom_image_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2) + 8, $bottom_image_y); /* //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, ($VAR_width + 20)/2 - $tmp_metrics['textWidth']/2, $VAR_height_difference); //$tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(140,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight() - 90; //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new+13); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new+12); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+11); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+10); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new+9); //$tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL, $VAR_PT_new + $bottom_image_y + 2); //$tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - 20, $VAR_PT_new + $bottom_image_y + 2); //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference + 38; //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - $tmp_chain_left->getImageWidth() + 14, $VAR_PT_new + $bottom_image_y - $tmp_chain_left->getImageHeight() + 6); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 1); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $core_width/2 + ($bottom_image_width/2) + $VAR_PL - $bottom_image_width*0.065, $VAR_PT_new + $bottom_image_y - $tmp_chain_right->getImageHeight() + 14); /* if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 1); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 51); } */ } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); $tmp_img_bottom_add->clear(); $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //name jewelry text double-plated with bottom image and no hook with custom fonts function FUNC_name_text_new_10a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $firstchar_color = isset($layer['firstcolor']) ? $layer['firstcolor'] : "black"; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_font2 = $PATH_components.'fonts/GreatVibes-Black.otf'; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color //if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "#bbbbbb"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; //} // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font2); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor("#ffffff"); //$draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(5, 30, $VAR_txt); // Create Canvas for Back Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Create a Clone of text canvas $tmp_txt_Clone0 = clone $tmp_txt_Canvas; // Clear text Canvas $draw->clear(); $tmp_txt_Canvas->clear(); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); */ // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } //$draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Set color and alpha for text $draw->setFillColor($text_color); //$draw->setFillColor($firstchar_color); $draw->setFont($VAR_font); // Add stroke around text //if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); //} //$tmp_metrics2 = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); // Draw text on canvas $draw->annotation(5, 30, $VAR_txt); //$draw->annotation(1-($tmp_metrics['textWidth']/2 - $tmp_metrics2['textWidth']/2), 0, $VAR_txt[0]); $tmp_txt_Canvas->drawImage($draw); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_image']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Bottom additional image $f_tmp = pathinfo($layer['bottom_image_add']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom_add = new Imagick($img_bottom_add); //Compute width of bottom image //$center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = $tmp_metrics['textWidth'] + 25; $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_img_bottom_add->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $bottom_image_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2) + 8, $bottom_image_y); $tmp_txt_Clone2 = clone $tmp_txt_Canvas; /* //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Clone2->compositeImage($tmp_txt_Clone0, imagick::COMPOSITE_DEFAULT, ($VAR_width + 20)/2 - $tmp_metrics['textWidth']/2, $VAR_height_difference); $tmp_Clone0 = clone $tmp_txt_Clone2; $tmp_Clone6 = clone $tmp_txt_Clone2; $tmp_Clone6->modulateImage(70,60,100); $tmp_txt_Clone2->clear(); $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, ($VAR_width + 20)/2 - $tmp_metrics['textWidth']/2, $VAR_height_difference); //$tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(30,60,100); $tmp_Clone2->modulateImage(50,60,100); $tmp_Clone3->modulateImage(100,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight() - 90; //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+13); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+12); //$tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+11); //$tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+10); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new+9); //$tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone6, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+11); $tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL, $VAR_PT_new + $bottom_image_y + 2); //$tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - 20, $VAR_PT_new + $bottom_image_y + 2); //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone0, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+4); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference + 38; //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - $tmp_chain_left->getImageWidth() + 14, $VAR_PT_new + $bottom_image_y - $tmp_chain_left->getImageHeight() + 6); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 1); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $core_width/2 + ($bottom_image_width/2) + $VAR_PL - $bottom_image_width*0.065 - 5, $VAR_PT_new + $bottom_image_y - $tmp_chain_right->getImageHeight() + 20); /* if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 1); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 51); } */ } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); $tmp_img_bottom_add->clear(); $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //name jewelry text double-plated with bottom image and no hook with custom fonts function FUNC_name_text_new_10b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $firstchar_color = isset($layer['firstcolor']) ? $layer['firstcolor'] : "black"; $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_font2 = $PATH_components.'fonts/GreatVibes-Black.otf'; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color //if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "#d79632"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; //} // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font2); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor("#f8e8cd"); //$draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(5, 30, $VAR_txt); // Create Canvas for Back Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Create a Clone of text canvas $tmp_txt_Clone0 = clone $tmp_txt_Canvas; // Clear text Canvas $draw->clear(); $tmp_txt_Canvas->clear(); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); */ // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } //$draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Set color and alpha for text $draw->setFillColor($text_color); //$draw->setFillColor($firstchar_color); $draw->setFont($VAR_font); // Add stroke around text //if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); //} //$tmp_metrics2 = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); // Draw text on canvas $draw->annotation(5, 30, $VAR_txt); //$draw->annotation(1-($tmp_metrics['textWidth']/2 - $tmp_metrics2['textWidth']/2), 0, $VAR_txt[0]); $tmp_txt_Canvas->drawImage($draw); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_image']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom = new Imagick($img_bottom); //Bottom additional image $f_tmp = pathinfo($layer['bottom_image_add']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom_add = new Imagick($img_bottom_add); //Compute width of bottom image //$center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = $tmp_metrics['textWidth'] + 25; $bottom_image_height = $tmp_img_bottom->getImageHeight(); $tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_img_bottom_add->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $bottom_image_height + 20, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($bottom_image_width/2) + 8, $bottom_image_y); $tmp_txt_Clone2 = clone $tmp_txt_Canvas; /* //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Clone2->compositeImage($tmp_txt_Clone0, imagick::COMPOSITE_DEFAULT, ($VAR_width + 20)/2 - $tmp_metrics['textWidth']/2, $VAR_height_difference); $tmp_Clone0 = clone $tmp_txt_Clone2; $tmp_Clone6 = clone $tmp_txt_Clone2; $tmp_Clone6->modulateImage(70,60,100); $tmp_txt_Clone2->clear(); $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, ($VAR_width + 20)/2 - $tmp_metrics['textWidth']/2, $VAR_height_difference); //$tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 0, $VAR_height_difference); // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(30,60,100); $tmp_Clone2->modulateImage(50,60,100); $tmp_Clone3->modulateImage(100,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight() - 90; //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); if($VAR_length > 1) { //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+13); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+12); //$tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+11); //$tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new+10); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new+9); //$tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone6, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new+11); $tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL, $VAR_PT_new + $bottom_image_y + 2); //$tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - 20, $VAR_PT_new + $bottom_image_y + 2); //Pendant Layer 1 $tmp_txt_Canvas->compositeImage($tmp_Clone0, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new+4); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference + 38; //$chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - $tmp_chain_left->getImageWidth() + 14, $VAR_PT_new + $bottom_image_y - $tmp_chain_left->getImageHeight() + 6); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 1); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $core_width/2 + ($bottom_image_width/2) + $VAR_PL - $bottom_image_width*0.065 - 5, $VAR_PT_new + $bottom_image_y - $tmp_chain_right->getImageHeight() + 20); /* if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 1); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 51); } */ } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); $tmp_img_bottom_add->clear(); $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with Dynamic Base Images function FUNC_name_text_new_11($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text //$arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; //Original text width $VAR_orig_width = $tmp_metrics['textWidth']; /* echo '
"; echo "VAR_height_ref: ".$VAR_height_ref."
"; echo "end_image_height: ".$end_image_height; echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ /* // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } */ $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 22, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 22, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); //use string length as basis for base image if($VAR_orig_width <= 67) { $str_len = 3; $VAR_xscale = 67/$VAR_orig_width; } else if($VAR_orig_width > 67 && $VAR_orig_width <= 83) { $str_len = 4; $VAR_xscale = 80/$VAR_orig_width; } else if($VAR_orig_width > 83 && $VAR_orig_width <= 99) { $str_len = 5; $VAR_xscale = 99/$VAR_orig_width; } else if($VAR_orig_width > 99 && $VAR_orig_width <= 115) { $str_len = 6; $VAR_xscale = 115/$VAR_orig_width; } else if($VAR_orig_width > 115 && $VAR_orig_width <= 131) { $str_len = 7; $VAR_xscale = 131/$VAR_orig_width; } else if($VAR_orig_width > 131 && $VAR_orig_width <= 147) { $str_len = 8; $VAR_xscale = 147/$VAR_orig_width; if($VAR_orig_width < 140) { $VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 147 && $VAR_orig_width <= 163) { $str_len = 9; $VAR_xscale = 163/$VAR_orig_width; if($VAR_orig_width < 158) { $VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 163) { $str_len = 10; $VAR_xscale = 179/$VAR_orig_width; if($VAR_orig_width > 280) { $VAR_rotation -= 15; $VAR_PL += 5; $VAR_PT -= 3; } else if($VAR_orig_width > 260) { $VAR_rotation -= 12; $VAR_PL += 3; $VAR_PT -= 2; } else if($VAR_orig_width > 240) { $VAR_rotation -= 10; $VAR_PL += 2; $VAR_PT -= 1; } else if($VAR_orig_width > 220) { $VAR_rotation -= 7; } else if($VAR_orig_width > 205) { $VAR_rotation -= 4; } else if($VAR_orig_width > 190) { $VAR_rotation -= 2; } else { if($VAR_orig_width >= 170 && $VAR_orig_width < 175) { $VAR_rotation += 1; $VAR_PL -= 12; } else if($VAR_orig_width > 163 && $VAR_orig_width < 170) { $VAR_rotation += 1; $VAR_PL -= 15; } } } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //Base Image $f_tmp = pathinfo($layer['base_img']); // Path of Base Image /*if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; }*/ if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->clear(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(50,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, 2, 3); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, -1, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, 0, -1); //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with Dynamic Base Images function FUNC_name_text_new_11a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text //$arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; //Original text width $VAR_orig_width = $tmp_metrics['textWidth']; /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ /* // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } */ $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 22, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 22, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); if($str_len == 3) { $VAR_xscale = 139/$VAR_orig_width; } else if($str_len == 4) { $VAR_xscale = 176/$VAR_orig_width; $VAR_PL -= 19; } else if($str_len == 5) { $VAR_xscale = 213/$VAR_orig_width; $VAR_PL -= 34; } else if($str_len == 6) { $VAR_xscale = 250/$VAR_orig_width; $VAR_PL -= 54; } else if($str_len == 7) { $VAR_xscale = 287/$VAR_orig_width; $VAR_PL -= 76; } else if($str_len == 8) { $VAR_xscale = 324/$VAR_orig_width; $VAR_PL -= 92; } else if($str_len == 9) { $VAR_xscale = 361/$VAR_orig_width; $VAR_PL -= 108; } else if($str_len == 10) { $VAR_xscale = 398/$VAR_orig_width; $VAR_PL -= 131; } /* //use string length as basis for base image if($VAR_orig_width <= 67) { $str_len = 3; $VAR_xscale = 67/$VAR_orig_width; } else if($VAR_orig_width > 67 && $VAR_orig_width <= 83) { $str_len = 4; $VAR_xscale = 80/$VAR_orig_width; } else if($VAR_orig_width > 83 && $VAR_orig_width <= 99) { $str_len = 5; $VAR_xscale = 99/$VAR_orig_width; } else if($VAR_orig_width > 99 && $VAR_orig_width <= 115) { $str_len = 6; $VAR_xscale = 115/$VAR_orig_width; } else if($VAR_orig_width > 115 && $VAR_orig_width <= 131) { $str_len = 7; $VAR_xscale = 131/$VAR_orig_width; } else if($VAR_orig_width > 131 && $VAR_orig_width <= 147) { $str_len = 8; $VAR_xscale = 147/$VAR_orig_width; if($VAR_orig_width < 140) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 147 && $VAR_orig_width <= 163) { $str_len = 9; $VAR_xscale = 163/$VAR_orig_width; if($VAR_orig_width < 158) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 163) { $str_len = 10; $VAR_xscale = 179/$VAR_orig_width; if($VAR_orig_width > 280) { //$VAR_rotation -= 15; $VAR_PL += 5; $VAR_PT -= 3; } else if($VAR_orig_width > 260) { //$VAR_rotation -= 12; $VAR_PL += 3; $VAR_PT -= 2; } else if($VAR_orig_width > 240) { //$VAR_rotation -= 10; $VAR_PL += 2; $VAR_PT -= 1; } else if($VAR_orig_width > 220) { //$VAR_rotation -= 7; } else if($VAR_orig_width > 205) { //$VAR_rotation -= 4; } else if($VAR_orig_width > 190) { //$VAR_rotation -= 2; } else { if($VAR_orig_width >= 170 && $VAR_orig_width < 175) { $VAR_rotation += 1; $VAR_PL -= 12; } else if($VAR_orig_width > 163 && $VAR_orig_width < 170) { //$VAR_rotation += 1; $VAR_PL -= 15; } } } */ // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //Base Image $f_tmp = pathinfo($layer['base_img']); // Path of Base Image /*if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; }*/ if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->clear(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(50,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, 2, 3); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, -1, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, 0, -1); //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with No Base Image, Hooks and Chains function FUNC_name_text_new_11b($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text //$arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; //Original text width $VAR_orig_width = $tmp_metrics['textWidth']; /* // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } */ $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 24, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 24, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); /* if($str_len == 3) { $VAR_xscale = 139/$VAR_orig_width; } else if($str_len == 4) { $VAR_xscale = 176/$VAR_orig_width; $VAR_PL -= 19; } else if($str_len == 5) { $VAR_xscale = 213/$VAR_orig_width; $VAR_PL -= 34; } else if($str_len == 6) { $VAR_xscale = 250/$VAR_orig_width; $VAR_PL -= 54; } else if($str_len == 7) { $VAR_xscale = 287/$VAR_orig_width; $VAR_PL -= 76; } else if($str_len == 8) { $VAR_xscale = 324/$VAR_orig_width; $VAR_PL -= 92; } else if($str_len == 9) { $VAR_xscale = 361/$VAR_orig_width; $VAR_PL -= 108; } else if($str_len == 10) { $VAR_xscale = 398/$VAR_orig_width; $VAR_PL -= 131; } */ /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ if($str_len == 3) { //$VAR_PT -= 9; if($VAR_orig_width > 134) { $VAR_xscale = 134/$VAR_orig_width; } } else if($str_len == 4) { //$VAR_PT -= 9; if($VAR_orig_width > 168) { $VAR_xscale = 168/$VAR_orig_width; } } else if($str_len == 5) { //$VAR_PT -= 9; if($VAR_orig_width > 202) { $VAR_xscale = 202/$VAR_orig_width; } } else if($str_len == 6) { //$VAR_PT -= 9; if($VAR_orig_width > 236) { $VAR_xscale = 236/$VAR_orig_width; } } else if($str_len >= 7) { if($VAR_orig_width > 236) { $VAR_xscale = 236/$VAR_orig_width; } if($str_len == 7) { $VAR_PT += 3; //$VAR_PT -= 6; } else { $VAR_PT += 6; //$VAR_PT -= 3; } } /* if($VAR_orig_width < 140) { $VAR_xscale = 140/$VAR_orig_width; $VAR_PT -= 10; $VAR_PL += 20; } else if($VAR_orig_width >=140 && $VAR_orig_width < 180) { $VAR_xscale = 170/$VAR_orig_width; $VAR_PT -= 8; $VAR_PL += 15; } else if($VAR_orig_width >=180 && $VAR_orig_width < 220) { $VAR_xscale = 210/$VAR_orig_width; $VAR_PT -= 8; $VAR_PL += 15; } else if($VAR_orig_width >=220 && $VAR_orig_width < 260) { $VAR_xscale = 220/$VAR_orig_width; $VAR_PT -= 6; $VAR_PL += 5; } else { $VAR_xscale = 230/$VAR_orig_width; } */ /* //use string length as basis for base image if($VAR_orig_width <= 67) { $str_len = 3; $VAR_xscale = 67/$VAR_orig_width; } else if($VAR_orig_width > 67 && $VAR_orig_width <= 83) { $str_len = 4; $VAR_xscale = 80/$VAR_orig_width; } else if($VAR_orig_width > 83 && $VAR_orig_width <= 99) { $str_len = 5; $VAR_xscale = 99/$VAR_orig_width; } else if($VAR_orig_width > 99 && $VAR_orig_width <= 115) { $str_len = 6; $VAR_xscale = 115/$VAR_orig_width; } else if($VAR_orig_width > 115 && $VAR_orig_width <= 131) { $str_len = 7; $VAR_xscale = 131/$VAR_orig_width; } else if($VAR_orig_width > 131 && $VAR_orig_width <= 147) { $str_len = 8; $VAR_xscale = 147/$VAR_orig_width; if($VAR_orig_width < 140) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 147 && $VAR_orig_width <= 163) { $str_len = 9; $VAR_xscale = 163/$VAR_orig_width; if($VAR_orig_width < 158) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 163) { $str_len = 10; $VAR_xscale = 179/$VAR_orig_width; if($VAR_orig_width > 280) { //$VAR_rotation -= 15; $VAR_PL += 5; $VAR_PT -= 3; } else if($VAR_orig_width > 260) { //$VAR_rotation -= 12; $VAR_PL += 3; $VAR_PT -= 2; } else if($VAR_orig_width > 240) { //$VAR_rotation -= 10; $VAR_PL += 2; $VAR_PT -= 1; } else if($VAR_orig_width > 220) { //$VAR_rotation -= 7; } else if($VAR_orig_width > 205) { //$VAR_rotation -= 4; } else if($VAR_orig_width > 190) { //$VAR_rotation -= 2; } else { if($VAR_orig_width >= 170 && $VAR_orig_width < 175) { $VAR_rotation += 1; $VAR_PL -= 12; } else if($VAR_orig_width > 163 && $VAR_orig_width < 170) { //$VAR_rotation += 1; $VAR_PL -= 15; } } } */ // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } /* //Base Image $f_tmp = pathinfo($layer['base_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->clear(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone->clear(); */ // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(50,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-1); //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with Base Image but no hooks and chains function FUNC_name_text_new_11c($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text //$arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; //Original text width $VAR_orig_width = $tmp_metrics['textWidth']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ /* // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } */ $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 10, $VAR_new_height + 10, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 22, new ImagickPixel("#fef7d3")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 22, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); /* if($str_len == 3) { $VAR_xscale = 139/$VAR_orig_width; } else if($str_len == 4) { $VAR_xscale = 176/$VAR_orig_width; $VAR_PL -= 19; } else if($str_len == 5) { $VAR_xscale = 213/$VAR_orig_width; $VAR_PL -= 34; } else if($str_len == 6) { $VAR_xscale = 250/$VAR_orig_width; $VAR_PL -= 54; } else if($str_len == 7) { $VAR_xscale = 287/$VAR_orig_width; $VAR_PL -= 76; } else if($str_len == 8) { $VAR_xscale = 324/$VAR_orig_width; $VAR_PL -= 92; } else if($str_len == 9) { $VAR_xscale = 361/$VAR_orig_width; $VAR_PL -= 108; } else if($str_len == 10) { $VAR_xscale = 398/$VAR_orig_width; $VAR_PL -= 131; } //use string length as basis for base image if($VAR_orig_width <= 67) { $str_len = 3; $VAR_xscale = 67/$VAR_orig_width; } else if($VAR_orig_width > 67 && $VAR_orig_width <= 83) { $str_len = 4; $VAR_xscale = 80/$VAR_orig_width; } else if($VAR_orig_width > 83 && $VAR_orig_width <= 99) { $str_len = 5; $VAR_xscale = 99/$VAR_orig_width; } else if($VAR_orig_width > 99 && $VAR_orig_width <= 115) { $str_len = 6; $VAR_xscale = 115/$VAR_orig_width; } else if($VAR_orig_width > 115 && $VAR_orig_width <= 131) { $str_len = 7; $VAR_xscale = 131/$VAR_orig_width; } else if($VAR_orig_width > 131 && $VAR_orig_width <= 147) { $str_len = 8; $VAR_xscale = 147/$VAR_orig_width; if($VAR_orig_width < 140) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 147 && $VAR_orig_width <= 163) { $str_len = 9; $VAR_xscale = 163/$VAR_orig_width; if($VAR_orig_width < 158) { //$VAR_rotation += 1; $VAR_PL -= 12; } } else if($VAR_orig_width > 163) { $str_len = 10; $VAR_xscale = 179/$VAR_orig_width; if($VAR_orig_width > 280) { //$VAR_rotation -= 15; $VAR_PL += 5; $VAR_PT -= 3; } else if($VAR_orig_width > 260) { //$VAR_rotation -= 12; $VAR_PL += 3; $VAR_PT -= 2; } else if($VAR_orig_width > 240) { //$VAR_rotation -= 10; $VAR_PL += 2; $VAR_PT -= 1; } else if($VAR_orig_width > 220) { //$VAR_rotation -= 7; } else if($VAR_orig_width > 205) { //$VAR_rotation -= 4; } else if($VAR_orig_width > 190) { //$VAR_rotation -= 2; } else { if($VAR_orig_width >= 170 && $VAR_orig_width < 175) { $VAR_rotation += 1; $VAR_PL -= 12; } else if($VAR_orig_width > 163 && $VAR_orig_width < 170) { //$VAR_rotation += 1; $VAR_PL -= 15; } } } */ // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //Base Image $f_tmp = pathinfo($layer['base_img']); // Path of Base Image /*if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; }*/ if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->clear(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(50,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, 2, 3); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, -1, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, 0, -1); //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } //Name Jewelry with Dynamic Base and Merged Chain Images function FUNC_name_text_new_11d($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //Change Default Text if($VAR_txt == "Name 1") { $VAR_txt = "NAME"; } //Split Text //$arr_str = str_split($VAR_txt); // split text $str_len = strlen($VAR_txt); $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Set Text Kerning $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { //$draw->setGravity(Imagick::GRAVITY_WEST); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; //Original text width $VAR_orig_width = $tmp_metrics['textWidth']; /* echo ''; echo "orig_width: ".$VAR_orig_width; echo ''; exit; */ /* // Manual x and y values of letters depending on string length $x_arr = explode(",", $layer['x'.$str_len]); $y_arr = explode(",", $layer['y'.$str_len]); for($i = 0; $i < $str_len; $i++) { ${"x$i"} = $x_arr[$i]; ${"y$i"} = $y_arr[$i]; } for ($j = 0; $j < count($arr_str); $j++) { $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset + ${"x$j"}; $sy = $shadow_yoffset + ${"y$j"}; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $arr_str[$j]); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { $tx = ${"x$j"}; $ty = ${"y$j"}; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $arr_str[$j]); $tx += $text_xoffset; $ty += $text_yoffset; } } } */ $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); $draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 22, new ImagickPixel("none")); } else { //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_height + 22, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); if($str_len == 3) { $VAR_xscale = 136/$VAR_orig_width; } else if($str_len == 4) { $VAR_xscale = 169/$VAR_orig_width; $VAR_PL -= 16; } else if($str_len == 5) { $VAR_xscale = 196/$VAR_orig_width; $VAR_PL -= 26; } else if($str_len == 6) { $VAR_xscale = 218/$VAR_orig_width; $VAR_PL -= 38; } else if($str_len == 7) { $VAR_xscale = 245/$VAR_orig_width; $VAR_PL -= 54; } else if($str_len == 8) { $VAR_xscale = 272/$VAR_orig_width; $VAR_PL -= 69; } else if($str_len == 9) { $VAR_xscale = 290/$VAR_orig_width; $VAR_PL -= 80; } else if($str_len == 10) { $VAR_xscale = 310/$VAR_orig_width; $VAR_PL -= 90; } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } //Dynamic Base Image $f_tmp = pathinfo($layer['base_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_base = new Imagick($img_base); $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->clear(); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_img_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_img_base->clear(); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(50,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(140,60,100); //$tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, 2, 3); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, -1, 0); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, 0, -1); //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, 0, 0); //Dynamic Chains Image $f_tmp = pathinfo($layer['base_chains']); if (file_exists($PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $chains_base = $PATH_components.$f_tmp['dirname'].'/F'.$str_len.'_'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $chains_base = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chains_base = new Imagick($chains_base); $tmp_txt_Canvas->compositeImage($tmp_chains_base, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chains_base->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_12($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); if($VAR_length > 8) { $str_len = 8; } else { $str_len = $VAR_length; } // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); /* //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "m") { $hookrightx = 90; } else if($VAR_txt[$VAR_length-1] == "r") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "t") { $hookrightx = 40; $hookrighty = 45; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 85; } else if($VAR_txt[$VAR_length-1] == "x") { $hookrightx = 50; } else if($VAR_txt[$VAR_length-1] == "y") { $hookrightx = 62; } else if($VAR_txt[$VAR_length-1] == "z") { $hookrightx = 52; } */ $hookleftx = 0; $hooklefty = 15; $hookrightx = 0; $hookrighty = 15; // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas if($VAR_length > 8) { $draw->annotation(0, -5, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); } // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'] + 20, $tmp_metrics['textHeight'], new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 90 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 100 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 78 * $VAR_size_factor + $VAR_center_adjust, 96 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 120 * $VAR_size_factor + $VAR_center_adjust, 92 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ if($str_len >= 8) { $VAR_new_textwidth = 400; } else if($str_len == 7) { $VAR_new_textwidth = 370; } else if($str_len == 6) { $VAR_new_textwidth = 330; } else if($str_len == 5) { $VAR_new_textwidth = 290; } else if($str_len == 4) { $VAR_new_textwidth = 255; } else { $VAR_new_textwidth = 235; } $VAR_PL_new = $VAR_PL + $VAR_width/2 - $VAR_new_textwidth/2; if($VAR_length > 8) { $tmp_txt_Canvas->resizeImage($VAR_new_textwidth, $tmp_txt_Canvas->getImageHeight()*0.95, imagick::FILTER_UNDEFINED, 1, FALSE); } else { $tmp_txt_Canvas->resizeImage($VAR_new_textwidth, $tmp_txt_Canvas->getImageHeight(), imagick::FILTER_UNDEFINED, 1, FALSE); } // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //With Image at bottom of text //Bottom center image - width is 53px based on $str_len $f_tmp = pathinfo($layer['bottom_image']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].$str_len.'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].$str_len.'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].$str_len.'.'.$f_tmp['extension']; } /* if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } */ $tmp_img_bottom = new Imagick($img_bottom); //Bottom additional image if(isset($layer['bottom_image_add'])) { $f_tmp = pathinfo($layer['bottom_image_add']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_bottom_add = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_img_bottom_add = new Imagick($img_bottom_add); } //Compute width of bottom image //$center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = $tmp_img_bottom->getImageWidth(); //$bottom_image_width = $tmp_metrics['textWidth'] + 100; $bottom_image_height = $tmp_img_bottom->getImageHeight(); //$tmp_img_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); if(isset($layer['bottom_image_add'])) { $tmp_img_bottom_add->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); } $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); //Codes for Tile Image start $f_tmp = pathinfo($layer['tile_img']); // Path of tile image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_tile = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_tile = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_tile = new Imagick($img_tile); $tmp_txt_Canvas = $tmp_txt_Canvas->textureImage($tmp_tile); // Create a Clone of tile $tmp_txt_tile = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); //$tmp_txt_Canvas->compositeImage($tmp_txt_Canvas2, imagick::COMPOSITE_DEFAULT, 0, 0); //Codes for Tile Image end // Create new canvas $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); /* //With Image at bottom of text //Bottom center image - width is 53px $f_tmp = pathinfo($layer['bottom_img_center']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_center_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_center_bottom = $PATH_components.'pendants/name-jewelry/37756/heart.png'; $tmp_center_bottom = new Imagick($img_center_bottom); // Bottom left image $f_tmp = pathinfo($layer['bottom_img_left']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_left_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_left_bottom = $PATH_components.'pendants/name-jewelry/37756/left-scroll.png'; $tmp_left_bottom = new Imagick($img_left_bottom); // Bottom Right image $f_tmp = pathinfo($layer['bottom_img_right']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_right_bottom = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_right_bottom = $PATH_components.'pendants/name-jewelry/37756/right-scroll.png'; $tmp_right_bottom = new Imagick($img_right_bottom); //$tmp_right_bottom->resizeImage($tmp_metrics['textWidth'] / 2,44,Imagick::FILTER_LANCZOS,1); //Compute width of bottom image $center_image_width = $tmp_center_bottom->getImageWidth(); $bottom_image_width = ($tmp_metrics['textWidth'] - $tmp_center_bottom->getImageWidth()) * 0.5; $bottom_image_height = $tmp_left_bottom->getImageHeight(); $tmp_left_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $tmp_right_bottom->resizeImage($bottom_image_width, $bottom_image_height, Imagick::FILTER_LANCZOS, 1); $bottom_image_y = isset($layer['bottom_img_y']) ? $layer['bottom_img_y'] : 0; // Create new canvas for Bottom image $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + $bottom_image_height, new ImagickPixel("none")); // Merge Bottom images to canvas if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 15); $tmp_txt_Canvas->compositeImage($tmp_left_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - $bottom_image_width - ($center_image_width/2) + 12, $bottom_image_y); $tmp_txt_Canvas->compositeImage($tmp_right_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 + ($center_image_width/2) + 8, $bottom_image_y); } else { $tmp_txt_Canvas->compositeImage($tmp_center_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_width/2 - ($center_image_width/2) + 10, $bottom_image_y + 28); } */ // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_tile, imagick::COMPOSITE_DEFAULT, 0, 0); $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DSTIN, 0, 0); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Clone1; $tmp_Clone2 = clone $tmp_txt_Clone1; $tmp_Clone3 = clone $tmp_txt_Clone1; $tmp_Clone4 = clone $tmp_txt_Clone1; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(30,60,100); $tmp_Clone2->modulateImage(50,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(100,100,100); // Clear text clone $tmp_txt_Clone1->clear(); // Clear text Canvas $tmp_txt_Canvas->clear(); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); //$tmp_Clone4->resizeImage($tmp_Clone4->getImageWidth()+10, $tmp_Clone1->getImageHeight(), imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image //$tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("#fef6b5")); $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $VAR_PT; //$VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); // Merge Bottom image to canvas $tmp_txt_Canvas->compositeImage($tmp_img_bottom, Imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width/2 - ($bottom_image_width/2) + 15, $VAR_PT_new + $bottom_image_y - 5); $f_tmp = pathinfo($layer['hook_img']); // Path of hook image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //Codes for Hook start //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width/2 - ($bottom_image_width/2) + 10, $VAR_PT + $hooklefty - 22); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_PL + $hookleftx + $VAR_center_adjust, $VAR_PT + $hooklefty + 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width/2 + ($bottom_image_width/2) - 2, $VAR_PT + $hookrighty - 27); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $VAR_PL + $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $VAR_PT + $hookrighty + 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } // Clear Hook Canvas $tmp_hook->clear(); //Codes for Hook end if($VAR_length > 1) { //Pendant Layer 1 //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new-8); //$tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-2, $VAR_PT_new-7); //$tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT_new-6); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new-6, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new-4, $VAR_PT_new-4); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new-2, $VAR_PT_new-6); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new, $VAR_PT_new-8); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new+2, $VAR_PT_new-6); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new+4, $VAR_PT_new-4); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL_new+6, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL_new+1, $VAR_PT_new); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL_new+1, $VAR_PT_new+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL_new-1, $VAR_PT_new-2); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL_new-1, $VAR_PT_new-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL_new, $VAR_PT_new); //$tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL-1, $VAR_PT_new+9); //$tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT_new); if(isset($layer['bottom_image_add'])) { $tmp_txt_Canvas->compositeImage($tmp_img_bottom_add, imagick::COMPOSITE_DEFAULT, $core_width/2 - ($bottom_image_width/2) + $VAR_PL - 20, $VAR_PT_new + $bottom_image_y + 2); } // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(40,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(100,60,100); //Pendant Layer 1 //$tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, 1, 2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, 1, 1); //$tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, -1, -2); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, -1, -1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, 0, 0); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT_new - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width/2 - ($bottom_image_width/2) - 20, $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y + 1); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT_new - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_PL + $VAR_width/2 + ($bottom_image_width/2) + 2, $VAR_chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y + 1); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 51); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); if(isset($layer['bottom_image_add'])) { $tmp_img_bottom_add->clear(); } $tmp_img_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Name Jewelry - Text with End Image function FUNC_name_text_dynamic_1($layer) { global $PATH_components, $core_width, $core_height, $productid, $txt_dynamic_position; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //Character spacing $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // Length of Text $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // End image $f_tmp = pathinfo($layer['end_img']); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_end = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_end_img = new Imagick($img_end); $end_image_width = $tmp_end_img->getImageWidth(); $end_image_height = $tmp_end_img->getImageHeight(); if($endimg_resize) { $tmp_end_img->resizeImage($end_image_width*0.9, $end_image_height*0.9, Imagick::FILTER_LANCZOS, 1); } //Getting Position of Hook by detecting edge of Character //if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Height of 1st character as reference for y position of right hook $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_height_ref = $tmp_metrics['ascender']; $hookrighty = $VAR_height_ref - $end_image_height - 10; /* echo ''; echo "hookrighty: ".$hookrighty."'; exit; */ // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook //for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $j; break; } } //} $draw->clear(); $tmp_txt_Canvas->clear(); /* // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); */ // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook //$hookrightx += 25; //$hookrighty = 35; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $hookrighty; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); /* } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } */ // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); /* // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "i") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "l") { $hookrightx = 48; } else if($VAR_txt[$VAR_length-1] == "s") { $hookrightx = 60; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 78; } */ // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { // Center of bottom Alignment of Text $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; $VAR_orig_character_height = $tmp_metrics['characterHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); $endimg_resize = true; } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_new_character_height = $tmp_metrics['characterHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20+ 30, $VAR_new_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_width + 20, $tmp_metrics['characterHeight'], new ImagickPixel("#eeeeee")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); /* // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } */ $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } //if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust - 2, $hooklefty - 10); /*} else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /* if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_center_adjust + $end_image_width - 15, $hookrighty - 15); //$tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust + 115, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } } */ // Clear Hook Canvas $tmp_hook->clear(); // Create a Clone of text canvas $tmp_txt_Clone1 = clone $tmp_txt_Canvas; // Clear text Canvas $tmp_txt_Canvas->clear(); // Create new canvas for End image $tmp_txt_Canvas->newImage($VAR_width + 160, $VAR_orig_height, new ImagickPixel("none")); // Vertical Adjustment to align text to bottom image $VAR_height_difference = $VAR_orig_character_height - $VAR_new_character_height; //Merge Text Canvas to Bottom Image Canvas $tmp_txt_Canvas->compositeImage($tmp_txt_Clone1, imagick::COMPOSITE_DEFAULT, 10, $VAR_height_difference); // Merge End image to canvas //if($VAR_length > 3) { if($endimg_resize) { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 3, 30); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 15, 20); } else { $tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust -4, $hookrighty - 18); //$tmp_txt_Canvas->compositeImage($tmp_end_img, Imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust - 6 - 18, 24); } //} $txt_dynamic_position[0] = $VAR_PL + $VAR_width - $VAR_center_adjust - 22; $txt_dynamic_position[1] = $VAR_PT + 18; // Clear text clone $tmp_txt_Clone1->clear(); // Make copies of Text with Bottom Image for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Create a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $VAR_PT_new = $core_height - $tmp_Clone2->getImageHeight(); //if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_width = $tmp_chain_left->getImageWidth(); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT - $VAR_height_difference; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, ($hookleftx*$hook_adjust_factor) + $VAR_center_adjust - $chain_left_width + 24, $hooklefty - $chain_left_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18-15, $hooklefty*$hook_adjust_factor - $chain_left_y); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT - $VAR_height_difference; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $VAR_width - $VAR_center_adjust + $end_image_width -15, $hookrighty*$hook_adjust_factor - $chain_right_y + 3); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 115, $hookrighty*$hook_adjust_factor - $chain_right_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28-15, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); } /*} else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } */ // Clear canvasses //$tmp_left_bottom->clear(); //$tmp_right_bottom->clear(); //$tmp_center_bottom->clear(); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Pendant or Bracelet function FUNC_text_monogram_2($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL - 105; } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; $VAR_PL = $VAR_PL - 65; $VAR_kern = -5; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z
"; echo "VAR_height_ref: ".$VAR_height_ref."
"; echo "end_image_height: ".$end_image_height; echo 'setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { $VAR_orig_width = $tmp_metrics['textWidth'] + 150; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; $hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(20, 0, $VAR_txt); } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_orig_width; $i++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hooklefty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookleftx = $i; break; } } //get position of right chain hook for ($i = $VAR_orig_width; $i >= 0; $i--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $i; break; } } $VAR_center_adjust = $VAR_PL + $core_width/2 - $VAR_orig_width/2 + 9; $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_hook = new Imagick($img_hook); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 17, $hooklefty - 10); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx - 3, $hookrighty - 10); $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + $VAR_chain_left_x - 17, $hooklefty - $chain_left_y + $VAR_chain_left_y + 6); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_chain_right_x - 3, $hookrighty - $chain_right_y + $VAR_chain_right_y + 6); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Pendant or Bracelet with Small 15px Hook function FUNC_text_monogram_2a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL - 105; } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; $VAR_PL = $VAR_PL - 65; $VAR_kern = -5; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth'] + 60; $VAR_orig_height = $tmp_metrics['textHeight']; } else { $VAR_orig_width = $tmp_metrics['textWidth'] + 150; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; if ( strlen($VAR_txt) == 1 ){ $hooklefty = $hookrighty = $VAR_orig_height*0.2; } else { $hooklefty = $hookrighty = $VAR_orig_height*0.3; } // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(20, 0, $VAR_txt); } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $VAR_orig_width; $i++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hooklefty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookleftx = $i; break; } } //get position of right chain hook for ($i = $VAR_orig_width; $i >= 0; $i--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $i; break; } } $VAR_center_adjust = $VAR_PL + $core_width/2 - $VAR_orig_width/2 + 9; $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_hook = new Imagick($img_hook); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 6, $hooklefty - 7); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx - 11, $hookrighty - 7); $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + $VAR_chain_left_x - 17, $hooklefty - $chain_left_y + $VAR_chain_left_y + 6); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_chain_right_x - 3, $hookrighty - $chain_right_y + $VAR_chain_right_y + 6); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Ring function FUNC_text_monogram_3($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 6; } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; //$VAR_kern = -5; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); // For Text //$draw->setFillColor($text_color); //$draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { $VAR_orig_width = $tmp_metrics['textWidth'] + 200; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { if($VAR_length > 1) { $draw->annotation($sx, $sy, $VAR_txt); } else { $draw->annotation($sx + 20, $sy, $VAR_txt); } $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } /* // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(20, 0, $VAR_txt); } */ // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { if($VAR_length > 1) { $draw->annotation($tx, $ty, $VAR_txt); } else { $draw->annotation($tx + 20, $ty, $VAR_txt); } $tx += $text_xoffset; $ty += $text_yoffset; } } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); /* //get position of left chain hook for ($i = 0; $i <= $VAR_orig_width; $i++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hooklefty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookleftx = $i; break; } } //get position of right chain hook for ($i = $VAR_orig_width; $i >= 0; $i--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $i; break; } } $VAR_center_adjust = $VAR_PL + $core_width/2 - $VAR_orig_width/2 + 9; $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_hook = new Imagick($img_hook); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 17, $hooklefty - 10); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx - 3, $hookrighty - 10); $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + $VAR_chain_left_x - 17, $hooklefty - $chain_left_y + $VAR_chain_left_y + 6); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_chain_right_x - 3, $hookrighty - $chain_right_y + $VAR_chain_right_y + 6); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); */ // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Jewelry with Larger Font Size function FUNC_text_monogram_4($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (40 * ($VAR_size / 86)); //$VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (1 * ($VAR_size / 86)); //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 6; } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; //$VAR_kern = -5; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); // For Text //$draw->setFillColor($text_color); //$draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { $VAR_orig_width = $tmp_metrics['textWidth'] + 200; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { if($VAR_length > 1) { $draw->annotation($sx, $sy, $VAR_txt); } else { $draw->annotation($sx + $VAR_size/4, $sy, $VAR_txt); //$draw->annotation($sx + 20, $sy, $VAR_txt); } $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } /* // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(20, 0, $VAR_txt); } */ // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { if($VAR_length > 1) { $draw->annotation($tx, $ty, $VAR_txt); } else { $draw->annotation($tx + $VAR_size/4, $ty, $VAR_txt); //$draw->annotation($tx + 2, $ty, $VAR_txt); } $tx += $text_xoffset; $ty += $text_yoffset; } } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); /* //get position of left chain hook for ($i = 0; $i <= $VAR_orig_width; $i++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hooklefty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookleftx = $i; break; } } //get position of right chain hook for ($i = $VAR_orig_width; $i >= 0; $i--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($i, $hookrighty); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrightx = $i; break; } } $VAR_center_adjust = $VAR_PL + $core_width/2 - $VAR_orig_width/2 + 9; $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_hook = new Imagick($img_hook); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx - 17, $hooklefty - 10); $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx - 3, $hookrighty - 10); $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + $VAR_chain_left_x - 17, $hooklefty - $chain_left_y + $VAR_chain_left_y + 6); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_chain_right_x - 3, $hookrighty - $chain_right_y + $VAR_chain_right_y + 6); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); */ // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Jewelry with Medium Font Size function FUNC_text_monogram_4a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."soufeel-flower.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (32 * ($VAR_size / 86)); $VAR_PT = $VAR_PT + (8 * ($VAR_size / 86)); //$VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (1 * ($VAR_size / 86)); $VAR_PT = $VAR_PT + (5 * ($VAR_size / 86)); //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 6; } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; //$VAR_kern = -5; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); // For Text //$draw->setFillColor($text_color); //$draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { $VAR_orig_width = $tmp_metrics['textWidth'] + 200; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { if($VAR_length > 1) { $draw->annotation($sx, $sy, $VAR_txt); } else { $draw->annotation($sx + $VAR_size/4, $sy, $VAR_txt); //$draw->annotation($sx + 20, $sy, $VAR_txt); } $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { if($VAR_length > 1) { $draw->annotation($tx, $ty, $VAR_txt); } else { $draw->annotation($tx + $VAR_size/4, $ty, $VAR_txt); //$draw->annotation($tx + 2, $ty, $VAR_txt); } $tx += $text_xoffset; $ty += $text_yoffset; } } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text for Earrings function FUNC_text_monogram_5($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 20; if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 5.6*$VAR_rotation; } } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; $VAR_kern = -8; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 4*$VAR_rotation; } } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { //$VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_width = $tmp_metrics['textWidth'] + 150; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); //$draw->annotation(20, 0, $VAR_txt); } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("#fef8b3")); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(60,60,100); $tmp_Clone2->modulateImage(80,60,100); $tmp_Clone3->modulateImage(90,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-9, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-6, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text Update 11/9/2020 function FUNC_text_monogram_6($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 20; if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 5.6*$VAR_rotation; } } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; $VAR_kern = -8; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 4*$VAR_rotation; } } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { //$VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_width = $tmp_metrics['textWidth'] + 150; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); //$draw->annotation(20, 0, $VAR_txt); } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("#fef8b3")); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(45,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(85,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+7); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+5); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); /* $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-9, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-6, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); */ $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Monogram Text with Connector function FUNC_text_monogram_6a($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ARA"; //Set Default Text if(strlen($VAR_txt) == 0 || strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); //Monogram Code change starts //Split Text $arr_str = str_split(strtolower($VAR_txt)); // split text // Library for replacing third character of text $__alphabetical = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $__symbol = array("1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","[","]","|",";"); // Additional width or height $scale_w = 0; $scale_h = 0; // Set font, text, position, stroke width if($layer['font_style'] == "Script") { // Script Font Style $VAR_font = $PATH_components.'fonts/'."vinesms.ttf"; //$VAR_font = $PATH_components.'fonts/'."vinemsb.ttf"; // 1 character if ( strlen($VAR_txt) == 1 ){ $VAR_txt = strtoupper($VAR_txt); // uppercase text //$VAR_txt = " ".strtoupper($VAR_txt)." "; // uppercase text $VAR_PL = $VAR_PL + (9 * ($VAR_size / 86)); // 2 characters }elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = $arr_str[0]. strtoupper($arr_str[1]); $VAR_PL = $VAR_PL - (18 * ($VAR_size / 86)); // 3 characters }else{ $VAR_txt = $arr_str[0].strtoupper($arr_str[1]).$arr_str[2]; } //$draw->setStrokeWidth(1); //$shad->setStrokeWidth(1); } else { // Block Font Style // 1 character if ( strlen($VAR_txt) == 1 ){ if($layer['font'] == "Circle") { $VAR_txt = strtoupper($VAR_txt); $VAR_font = $PATH_components.'fonts/'."circle_1.ttf"; $VAR_PL = $VAR_PL + 20; if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 5.6*$VAR_rotation; } } // 2 characters } elseif ( strlen($VAR_txt) == 2 ){ $VAR_txt = strtolower($arr_str[0]).strtoupper($arr_str[1]); if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_2.ttf"; //$VAR_PL = $VAR_PL - 65; $VAR_kern = -8; //$VAR_PL = $VAR_PL - (18 * ($VAR_size / 160)); if($VAR_rotation < 0){ $VAR_PT = $VAR_PT - 4*$VAR_rotation; } } // 3 characters }else{ $i = 0; for( $i ; $i< strlen($VAR_txt); $i++ ){ if($i==0){ $str_a = strtolower($arr_str[$i]); }elseif($i==1){ $str_b = strtoupper($arr_str[$i]); }elseif($i==2){ if($layer['font'] == "Circle") { $VAR_font = $PATH_components.'fonts/'."circle_3.ttf"; for($z=0;$z setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //$VAR_orig_width = $tmp_metrics['textWidth']; //$VAR_orig_height = $tmp_metrics['textHeight']; //Original text width/height if($layer['font_style'] == "Script") { $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; } else { //$VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_width = $tmp_metrics['textWidth'] + 150; $VAR_orig_height = $tmp_metrics['textHeight']; } // Original Font Size $VAR_orig_size = $VAR_size; $VAR_center_adjust = ($VAR_orig_width - $tmp_metrics['textWidth'])/2; //$hooklefty = $hookrighty = $VAR_orig_height/2; // Draw text on canvas if($VAR_length > 1) { $draw->annotation(0, 0, $VAR_txt); } else { $draw->annotation(0, 0, $VAR_txt); //$draw->annotation(20, 0, $VAR_txt); } $tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("none")); //$tmp_txt_Canvas->newImage($VAR_orig_width, $VAR_orig_height, new ImagickPixel("#fef8b3")); $tmp_txt_Canvas->drawImage($draw); //Add connector if($VAR_length > 1) { $f_tmp = pathinfo($layer['connector_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_connector1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_connector2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_connector1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_connector2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } if (file_exists($img_connector1) && file_exists($img_connector2)) { if($VAR_length == 2) { $tmp_connector = new Imagick($img_connector2); $tmp_txt_Canvas->compositeImage($tmp_connector, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, ($VAR_orig_height - $tmp_connector->getImageHeight())/2); } else { $tmp_connector = new Imagick($img_connector1); $tmp_txt_Canvas->compositeImage($tmp_connector, imagick::COMPOSITE_DEFAULT, $VAR_center_adjust, ($VAR_orig_height - $tmp_connector->getImageHeight())/2); } $tmp_connector->clear(); } } // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_orig_width)*$VAR_xscale, ($VAR_orig_height)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(45,60,100); $tmp_Clone2->modulateImage(70,60,100); $tmp_Clone3->modulateImage(85,60,100); $tmp_Clone4->modulateImage(120,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+7); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+5); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); /* $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL-9, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL-6, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL-3, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); */ $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_initial_1($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "A"; //Set Default Text if(strlen($VAR_txt) > 1) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Array of lowercase letters with no ascender and descender, except j which has both $no_ascender_descender = array("a", "c", "j", "e", "m", "n", "o", "r", "s", "u", "v", "w", "x", "z"); // Array of lowercase letters with ascender $with_ascender = array("b", "d", "f", "h", "i", "k", "l", "t"); // Array of lowercase letters with descender $with_descender = array("g", "p", "q", "y"); // Get Font Metrics $tmp_metrics = ""; //Get X_Height - text height of lowercase letters with no ascender and descender, ex. a, c, etc. $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, "a"); $text_xheight = $tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); if(ctype_lower($VAR_txt)) { //bounding box height $bbheight = $tmp_metrics['boundingBox']['y2'] - $tmp_metrics['boundingBox']['y1']; if(in_array($VAR_txt, $with_ascender)) { $VAR_PT = $VAR_PT + (($bbheight - $text_xheight)/3); } else if(in_array($VAR_txt, $with_descender)) { $VAR_PT = $VAR_PT - (($bbheight - $text_xheight)/3); } } $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } /* echo ' '; echo $VAR_txt."'; exit; */ //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } // Text Engraving New function FUNC_text_initial_3($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; $VAR_init_val = isset($layer['init_value']) ? $layer['init_value'] : "ABC"; //Set Default Text if(strlen($VAR_txt) > 3) $VAR_txt = $VAR_init_val; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Add kern attribute to text $VAR_kern = isset($layer['kern']) ? $layer['kern'] : 0; //Add split_year attribute to text $VAR_split_year = isset($layer['split_year']) ? $layer['split_year'] : 0; if($VAR_split_year > 0) { $year_split = str_split($VAR_txt, 2); if($VAR_split_year == 1) { $VAR_txt = $year_split[0]; } else if($VAR_split_year == 2) { $VAR_txt = $year_split[1]; } } // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); //Add kerning to increase spacing of characters if($VAR_kern > 0) $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); if($VAR_kern > 0) $draw->setTextKerning($VAR_kern/2); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_top_text_upper3($layer, $engraved, $text_angle) { global $PATH_components, $core_width, $core_height; $VAR_txt_1 = $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; //$VAR_txt_2 = $VAR_txt = isset($layer['txt_2']) ? $layer['txt_2'] : ""; $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; $VAR_height = isset($layer['height']) ? $layer['height'] : 0; $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; //$VAR_star_size = isset($layer['star_size']) ? $layer['star_size'] : 0; //$VAR_star_y = isset($layer['star_y']) ? $layer['star_y'] : 0; $VAR_color = isset($layer['color']) ? $layer['color'] : "black"; $VAR_em_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $VAR_shadow_color = "black"; // always use black for now // To overwrite metal color if($layer['usecolor']) { $VAR_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $VAR_em_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_emb_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 5; $VAR_side_padding = isset($layer['side_pad']) ? $layer['side_pad'] : 0; $VAR_font_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_arc_top_rad = isset($layer['arc_top_rad']) ? $layer['arc_top_rad'] : 0; $VAR_arc_bot_rad = isset($layer['arc_bot_rad']) ? $layer['arc_bot_rad'] : 0; $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; $VAR_rect = isset($layer['rect']) ? $layer['rect'] : 0; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_txt_1 = " ".$VAR_txt_1." "; //$VAR_txt_2 = " ".$VAR_txt_2." "; $tmp_txt_Canvas = new Imagick(); $draw = new ImagickDraw(); if($engraved) { $draw->setFillColor($VAR_color); } else { $draw->setFillColor($VAR_em_color); } //$draw->setFillColor($VAR_em_color); $draw->setFont($VAR_font); $draw->setFontSize($VAR_font_size); $draw->setTextAntialias(true); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $ln = strlen($VAR_txt_1); //$ln = strlen($VAR_txt_1) + strlen($VAR_txt_2); $ln = $ln - 1; //$ln = $ln - 2; if($ln == 1) { $VAR_kern = 300; }else if($ln == 2) { $VAR_kern = 200; }else if($ln == 3) { $VAR_kern = 150; }else if($ln == 4) { $VAR_kern = 100; }else if($ln == 5) { $VAR_kern = 50; }else if($ln == 6) { $VAR_kern = 20; }else if($ln > 6) { $VAR_kern = 10; } if($ln > 10) $VAR_kern = 7; if($ln > 13) $VAR_kern = 5; if($ln > 18) $VAR_kern = 1; $draw->setTextKerning($VAR_kern); $tmp_metrics = array(); $tmp_metrics['U'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_1); //$tmp_metrics['D'] = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt_2); $VAR_txt_width = $tmp_metrics['U']['textWidth'] + $tmp_metrics['D']['textWidth'] + ($VAR_side_padding * 4); $VAR_txt_height = max($tmp_metrics['U']['textHeight'],$tmp_metrics['D']['textHeight']); $tmp_txt_Canvas->newImage($VAR_txt_width, $VAR_txt_height, new ImagickPixel("none")); // Text for ($i = 1; $i <= $VAR_emb_depth; $i++) { $draw->annotation($VAR_side_padding, $i-6, $VAR_txt_1); } if($engraved) { $draw->setFillColor($VAR_shadow_color); } else { $draw->setFillColor($VAR_color); } $draw->annotation($VAR_side_padding, -6, $VAR_txt_1); $tmp_txt_Canvas->drawImage($draw); $VAR_D = ($VAR_txt_width / 2) - (($tmp_metrics['U']['textWidth'] / 2) + ($VAR_side_padding)); $VAR_deg = ($VAR_D / $VAR_txt_width) * $text_angle; //$VAR_deg = ($VAR_D / $VAR_txt_width) * 360; /* Perform the distortion */ $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array($text_angle, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(360, $VAR_deg, $VAR_arc_top_rad, $VAR_arc_bot_rad), false); //Distort to oval $tmp_txt_Canvas->scaleimage($VAR_width, $VAR_height, false); $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_rect > 0) { $VAR_txt_c_w = $VAR_txt_c_w + ($VAR_rect * 2); $VAR_txt_c_h = $VAR_txt_c_h + ($VAR_rect * 2); $points = array( $VAR_rect,$VAR_rect, 0,0, # top left $VAR_rect, ($VAR_txt_c_h - $VAR_rect), 0, $VAR_txt_c_h, # bottom left ($VAR_txt_c_w - $VAR_rect),$VAR_rect, $VAR_txt_c_w,0, # top right ($VAR_txt_c_w - $VAR_rect),($VAR_txt_c_h - $VAR_rect), $VAR_txt_c_w ,$VAR_txt_c_h # bottom right ); $tmp_shep_Canvas = new Imagick(); $tmp_shep_Canvas->newImage($tmp_txt_Canvas->getImageWidth() + ($VAR_rect * 2),$tmp_txt_Canvas->getImageHeight() + ($VAR_rect * 2), new ImagickPixel("none")); $tmp_shep_Canvas->compositeImage($tmp_txt_Canvas, imagick::COMPOSITE_DEFAULT, $VAR_rect,$VAR_rect); $tmp_shep_Canvas->distortImage( Imagick::DISTORTION_SHEPARDS, $points, false ); $tmp_txt_Canvas = $tmp_shep_Canvas; //$tmp_shep_Canvas->destroy(); } if((isset($VAR_rotation) && $VAR_rotation != 0)) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $VAR_txt_c_w = $tmp_txt_Canvas->getImageWidth(); $VAR_txt_c_h = $tmp_txt_Canvas->getImageHeight(); if($VAR_perspective > 0) { $controlPoints = array( 0, 0, $VAR_perspective, 0, 0, $VAR_txt_c_h, 0, $VAR_txt_c_h, $VAR_txt_c_w, 0, $VAR_txt_c_w - $VAR_perspective, 0, $VAR_txt_c_w, $VAR_txt_c_h, $VAR_txt_c_w, $VAR_txt_c_h); $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); } return array('txt_canvas' => $tmp_txt_Canvas, '_x' => $VAR_PL, '_y' => $VAR_PT); } function FUNC_text_Arc_Tree($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point //$VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point //$VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); //$VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); // $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height // $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); //$tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, array(180, 45, 100, 20), false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_New_1dt($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script MT"; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 0; $VAR_length = strlen($VAR_txt); //echo $VAR_txt[$VAR_length-1].'&****'.$VAR_txt[0];exit; if($VAR_txt[$VAR_length-1] || $VAR_txt[0]) { //$VAR_size=10; } // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); //$draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; $tmp_txt_Canvas->newPseudoImage('radial-gradient:red-blue'); if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->setImagePage($tmp_txt_Canvas->getimageWidth(), $tmp_txt_Canvas->getimageheight(), 0, 0); $tmp_txt_Canvas->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT); $tmp_txt_Canvas->setImageMatte(true); if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_New_1d($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script MT"; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 0; $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); //$draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); $draw->setTextKerning($VAR_kern); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); //$draw->setFontSize(48); $draw->setStrokeAntialias(true); $draw->setTextAntialias(true); //$draw->setFillColor('#ff0000'); if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; $tmp_txt_Canvas->newPseudoImage('radial-gradient:red-blue'); if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } $tmp_txt_Canvas->setImagePage($tmp_txt_Canvas->getimageWidth(), $tmp_txt_Canvas->getimageheight(), 0, 0); $tmp_txt_Canvas->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT); $tmp_txt_Canvas->setImageMatte(true); if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_2d($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha $VAR_kern = isset($layer['kern']) ? $layer['kern'] : -3; $VAR_fontname = isset($layer['font']) ? $layer['font'] : "Brush Script Std"; //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; //$VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); if($VAR_fontname == "Harlow Solid Italic") { if($hookrighty < 35) { $hookrighty = 35; } } // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); } if($VAR_fontname == "Linoscript") { if ($hookleftx > 16) { $hookleftx = 16; } } else { if($VAR_fontname == "HELVETI1") { if($VAR_txt[$VAR_length-1] == "S" || $VAR_txt[$VAR_length-1] == "O") { $hooklefty = 28; $hookleftx = 4; } $no_asc = array("G","F","C"); $first_char = array("H"); if (in_array($VAR_txt[$VAR_length-1], $no_asc)) { if (in_array($VAR_txt[0], $first_char)) { $hookleftx = 2; $hooklefty = 18; } } } if($VAR_fontname !== "Harlow Solid Italic") { // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } } } if($VAR_fontname == "Commercial") { $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("R","T","H","P","S","U","V","W","X","E"); if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { $hookleftx = 53; $hooklefty = 42; } else if($VAR_txt[0] == "Z") { $hookleftx = 41; } } $first_char_position1 = array("M","W"); if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position1)) { $hookleftx = 50; //$hooklefty = 42; } else if($VAR_txt[0] == "Z") { $hookleftx = 10; $hooklefty = 5; } } if($VAR_txt[$VAR_length-1] == "j") { $hookrightx = 88; $hooklefty = 55; $hookleftx = 55; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension'])) { $img_bridge3 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'3.'.$f_tmp['extension']; $tmp_bridge3 = new Imagick($img_bridge3); //$tmp_bridge3->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge3->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); } if($VAR_fontname == "Linoscript") { if($VAR_txt[0] == "B") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 84 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 74 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "E") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 46 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "G") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 60 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 50 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "J") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 62 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 54 * $VAR_size_factor + $VAR_center_adjust, 77 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 48 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "S") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 56 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 44 * $VAR_size_factor + $VAR_center_adjust, 74 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 78 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 94 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Y") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } else if($VAR_txt[0] == "Z") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 66 * $VAR_size_factor + $VAR_center_adjust, 76 * $VAR_size_factor); } } else if($VAR_fontname == "Harlow Solid Italic") { if($VAR_txt[0] == "N") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 134 * $VAR_size_factor + $VAR_center_adjust, 98 * $VAR_size_factor); } else if($VAR_txt[0] == "U") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 102 * $VAR_size_factor + $VAR_center_adjust, 94 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 98 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge3, imagick::COMPOSITE_DEFAULT, 142 * $VAR_size_factor + $VAR_center_adjust, 88 * $VAR_size_factor); } } else { if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust-5, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } } if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 13, $hookrighty - 28); } } $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $VAR_chain_left_x = isset($layer['chain_left_x']) ? $layer['chain_left_x'] : 0; $VAR_chain_left_y = isset($layer['chain_left_y']) ? $layer['chain_left_y'] : 0; $VAR_chain_right_x = isset($layer['chain_right_x']) ? $layer['chain_right_x'] : 0; $VAR_chain_right_y = isset($layer['chain_right_y']) ? $layer['chain_right_y'] : 0; $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust + $VAR_chain_left_x, $hooklefty*$hook_adjust_factor - $chain_left_y + $VAR_chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + $VAR_chain_right_x, $hookrighty*$hook_adjust_factor - $chain_right_y + $VAR_chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+3); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT+2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT+1); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); } } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_text_Arc_New_1e($layer) { global $PATH_components, $core_width, $core_height; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $text_alpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $text_xoffset = isset($layer['txoffset']) ? $layer['txoffset'] : 0; // Text horizontal position offset $text_yoffset = isset($layer['tyoffset']) ? $layer['tyoffset'] : 0; // Text vertical position offset $text_depth = isset($layer['tdepth']) ? $layer['tdepth'] : 0; // Text vertical position offset //$shadow_color = "black"; // always use black for now $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } // To add stroke color if($layer['stroke']) { $stroke_color = isset($layer['strokecolor']) ? $layer['strokecolor'] : "white"; $stroke_width = isset($layer['strokewidth']) ? $layer['strokewidth'] : 1; } //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; if($layer['font'] == "Arial") { // Array of lowercase letters with no ascender $first_char_position = array("C","G","O","S","Q","","","U","",""); if (in_array($VAR_txt, $first_char_position)) { $VAR_PT = 438; $VAR_PL = 6; $VAR_width= 45; } else if($VAR_txt == "B"){ $VAR_PT = 439; $VAR_PL = 13; } else if($VAR_txt == "I"){ $VAR_height = 180; $VAR_width = 40; $VAR_PT = 420; $VAR_PL = 22; } else if($VAR_txt == "W" || $VAR_txt == "V" || $VAR_txt == "A" || $VAR_txt == "Y"){ $VAR_height = 230; $VAR_width = 38; $VAR_PT = 455; $VAR_PL = 2; } else if($VAR_txt == "D") { $VAR_width= 40; $VAR_PT = 443; $VAR_PL = 13; $VAR_height = 216; } } // Distortion Parameters $VAR_textformat = isset($layer['textformat']) ? $layer['textformat'] : "none"; // Type of Distortion on text canvas $VAR_rotation = isset($layer['rotation']) ? $layer['rotation'] : 0; // Rotation of text canvas $VAR_skewx = isset($layer['skewx']) ? $layer['skewx'] : 0; // Horizontal skew of text canvas $VAR_skewy = isset($layer['skewy']) ? $layer['skewy'] : 0; // Vertical skew of text canvas $VAR_xscale = isset($layer['xscale']) ? $layer['xscale'] : 1; // Horizontal resizing of text canvas $VAR_yscale = isset($layer['yscale']) ? $layer['yscale'] : 1; // Vertical resizing of text canvas $VAR_perspective = isset($layer['perspective']) ? $layer['perspective'] : 0; // Vertical resizing of text canvas // Distortion Arc Parameters $VAR_direction = isset($layer['direction']) ? $layer['direction'] : 'CW'; // Direction of text arc $VAR_args = isset($layer['arc_args']) ? $layer['arc_args'] : 0; // Prameters of text arc: degree - rotation - outer radius - inside radius $VAR_args = explode("-", $VAR_args); // Adjustment on Text vertical position, position of Arial as reference point $VAR_PT = $VAR_PT - ($VAR_font_ARR['minus_y']*($VAR_size/40)); // Adjustment on Font size, 40 as reference point $VAR_size = $VAR_size - ($VAR_font_ARR['minus_size']*($VAR_size/40)); $VAR_size = $VAR_size + 8; //$VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); //$draw->setFillAlpha($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); //$draw->setTextAlignment(imagick::ALIGN_CENTER); // Add stroke around text if($layer['stroke']) { $draw->setStrokeWidth($stroke_width); $draw->setStrokeOpacity(1); $draw->setStrokeColor($stroke_color); } if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_CENTER); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_PT = $VAR_PT - $VAR_height; //$VAR_PT = $VAR_PT - $tmp_metrics['textHeight']; //Original text height $VAR_orig_height = $tmp_metrics['textHeight']; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { //if((isset($VAR_fit) && $VAR_fit != 0)) { if(!empty($tmp_metrics['textWidth'])) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; $VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } // Draw text shadow on canvas if((isset($shadow_depth) && $shadow_depth != 0)) { // Draw shadow text $sx = $shadow_xoffset; $sy = $shadow_yoffset; for ($i = 1; $i <= $shadow_depth; $i++) { $draw->annotation($sx, $sy, $VAR_txt); $sx += $shadow_xoffset; $sy += $shadow_yoffset; } } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($text_alpha); //$draw->setFillAlpha($talpha); $draw->setStrokeWidth(0); $draw->setStrokeOpacity(0); // Draw text on canvas if((isset($text_depth) && $text_depth != 0)) { // Draw text if($VAR_align == 'left' || $VAR_align == 'right') { $tx = 2; } else { $tx = 0; } $ty = 0; for ($i = 1; $i <= $text_depth; $i++) { $draw->annotation($tx, $ty, $VAR_txt); $tx += $text_xoffset; $ty += $text_yoffset; } } //$draw->annotation(0, 0, $VAR_txt); if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height + 20, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_orig_height + 20, new ImagickPixel("none")); } //$tmp_txt_Canvas->annotateImage($draw, 0, 0, $VAR_rotation, $VAR_txt); $tmp_txt_Canvas->drawImage($draw); // Resize text due to xscale/yscale values $tmp_txt_Canvas->resizeImage(($VAR_width+20)*$VAR_xscale, ($VAR_height+20)*$VAR_yscale, imagick::FILTER_UNDEFINED, 1); //Set value for Perspecive Distortion $VAR_delta = $VAR_args[0] * (0.017 * $VAR_perspective) * $VAR_height; //$VAR_delta = $VAR_args[0] * (3.14/180) * $VAR_height; if($VAR_direction == 'CCW') { $controlPoints = array( 0, 0, 0, 0, 0, $tmp_txt_Canvas->getImageHeight(), $VAR_delta/2, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), $tmp_txt_Canvas->getImageHeight()); } else { $controlPoints = array( 0, 0, $VAR_delta/2, 0, 0, $tmp_txt_Canvas->getImageHeight(), 0, $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), 0, $tmp_txt_Canvas->getImageWidth() - ($VAR_delta/2), 0, $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight(), $tmp_txt_Canvas->getImageWidth(), $tmp_txt_Canvas->getImageHeight()); } if($VAR_perspective != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false); if($VAR_direction == 'CCW') { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), 180); } if($VAR_args != 0) $tmp_txt_Canvas->distortImage(Imagick::DISTORTION_ARC, $VAR_args, false); if(($VAR_skewx != 0) || $VAR_skewy != 0) { $tmp_txt_Canvas->shearImage(new ImagickPixel('none'), $VAR_skewx, $VAR_skewy); } if($VAR_rotation != 0) { $tmp_txt_Canvas->rotateImage(new ImagickPixel('none'), $VAR_rotation); } $tmp_Clone = clone $tmp_txt_Canvas; $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); $tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); return array('txt_canvas' => $tmp_txt_Canvas); } function FUNC_name_text_new_1v($layer) { global $PATH_components, $core_width, $core_height, $productid; // Parameters passed from attributes of Layer XML // Basic Parameters $VAR_width = isset($layer['width']) ? $layer['width'] : $core_width; // Text Canvas Width $VAR_fit = isset($layer['fit']) ? $layer['fit'] : 0; // Resize Text to Fit Text Canvas Width $VAR_height = isset($layer['height']) ? $layer['height'] : 0; // Text Canvas Height, use as reference $VAR_PT = isset($layer['top']) ? $layer['top'] : 0; // Text Canvas top position $VAR_PL = isset($layer['left']) ? $layer['left'] : 0; // Text Canvas left position $VAR_PR = isset($layer['right']) ? $layer['right'] : 0; // Text Canvas right position $VAR_align = isset($layer['align']) ? $layer['align'] : "center"; // Alignment of text on canvas $VAR_txt = isset($layer['txt']) ? $layer['txt'] : ""; // Color Parameters $text_color = isset($layer['color']) ? $layer['color'] : "black"; $talpha = isset($layer['talpha']) ? $layer['talpha'] : 1; // Text alpha $shadow_color = isset($layer['scolor']) ? $layer['scolor'] : "black"; $shadow_xoffset = isset($layer['sxoffset']) ? $layer['sxoffset'] : 0; // Text Shadow horizontal position offset $shadow_yoffset = isset($layer['syoffset']) ? $layer['syoffset'] : 0; // Text Shadow vertical position offset $shadow_depth = isset($layer['sdepth']) ? $layer['sdepth'] : 0; // Text Shadow vertical position offset $shadow_alpha = isset($layer['salpha']) ? $layer['salpha'] : 1; // Text Shadow alpha //Font parameters $VAR_font_ARR = ""; if(isset($layer['font']) and is_array($layer['font'])) { $VAR_font_ARR = $layer['font']; }else if(is_string($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', $layer['font']); }else if(!isset($layer['font'])) { $VAR_font_ARR = FUNC_get_XML('font', 'Arial'); } $VAR_font = $PATH_components.'fonts/'.$VAR_font_ARR['file_name']; $VAR_size = isset($layer['size']) ? $layer['size'] : 10; $VAR_kern = -3; // To overwrite metal color if($layer['usecolor']) { $text_color = isset($layer['ucolor']) ? $layer['ucolor'] : "black"; $shadow_color = isset($layer['uscolor']) ? $layer['uscolor'] : "black"; } $VAR_length = strlen($VAR_txt); // Create text canvas $tmp_txt_Canvas = new Imagick(); // Set draw parameters $draw = new ImagickDraw(); //Getting Position of Hook by detecting edge of Character /*if($VAR_length > 1) { // Get Position of hook for last character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[$VAR_length-1]); $VAR_width_last = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[$VAR_length-1]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of right chain hook for ($i = 0; $i <= $VAR_height; $i++) { for ($j = $VAR_width_last; $j >= 0; $j--) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hookrighty = $i; $hookrightx = $j; break 2; } } } $draw->clear(); $tmp_txt_Canvas->clear(); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); // Get Position of hook for 1st character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //Use same height as right hook $i = $hookrighty; for ($j = 0; $j <= $VAR_width_first; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($j, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $j; break; } } $draw->clear(); $tmp_txt_Canvas->clear(); } else { // Get Position of hook for 1 character $draw->setFillColor($text_color); $draw->setfillopacity($talpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); $draw->setTextAntialias(true); //$VAR_kern = -4; $draw->setTextKerning($VAR_kern); $draw->setGravity(Imagick::GRAVITY_SOUTHWEST); // Get Width of first character $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt[0]); $VAR_width_first = $tmp_metrics['textWidth']; // Draw text on canvas $draw->annotation(0, 0, $VAR_txt[0]); $tmp_txt_Canvas->newImage($tmp_metrics['textWidth'], $tmp_metrics['textHeight'], new ImagickPixel("none")); $tmp_txt_Canvas->drawImage($draw); //get position of left chain hook for ($i = 0; $i <= $tmp_metrics['textHeight']; $i++) { //Check Middle Area //for ($j = ($VAR_width_first/2)-1; $j <= ($VAR_width_first/2)+1; $j++) { $pixel = $tmp_txt_Canvas->getImagePixelColor($VAR_width_first/2, $i); $colors = iMagickColorToHEX($pixel->getColorAsString()); if($colors !== '#000') { $hooklefty = $i; $hookleftx = $VAR_width_first/2; break; } //} } $draw->clear(); $tmp_txt_Canvas->clear(); }*/ // Array of lowercase letters with no ascender $no_ascender = array("a", "c", "e", "g","i", "j", "m", "n","o", "p", "q", "r","s", "u", "v", "w","x", "y", "z"); $first_char_position = array("B","D","F","H","K","M","N","P","R","T","U","V","W","X"); // Manual position of Left Hook for First Capital Letter for Last Letter with no Ascender if (in_array($VAR_txt[$VAR_length-1], $no_ascender)) { if (in_array($VAR_txt[0], $first_char_position)) { //if($VAR_txt[0] == "B" || $VAR_txt[0] == "D" || $VAR_txt[0] == "F" || $VAR_txt[0] == "H" || $VAR_txt[0] == "K" || $VAR_txt[0] == "M" || $VAR_txt[0] == "N" || $VAR_txt[0] == "P" || $VAR_txt[0] == "R" || $VAR_txt[0] == "T" || $VAR_txt[0] == "U" || $VAR_txt[0] == "V" || $VAR_txt[0] == "W" || $VAR_txt[0] == "X") { $hookleftx = 10; } else if($VAR_txt[0] == "E") { $hookleftx = 14; } } // Manual position of Right Hook for last character if($VAR_txt[$VAR_length-1] == "u") { $hookrightx = 42; } else if($VAR_txt[$VAR_length-1] == "w") { $hookrightx = 55; } // For Text Shadow $draw->setFillColor($shadow_color); $draw->setfillopacity($shadow_alpha); $draw->setFont($VAR_font); $draw->setFontSize($VAR_size); //$draw->setFontStretch(Imagick::STRETCH_ULTRAEXPANDED); $draw->setTextAntialias(true); $draw->setTextKerning($VAR_kern); if($VAR_align == 'left') { $draw->setGravity(Imagick::GRAVITY_WEST); } else if($VAR_align == 'right') { $draw->setGravity(Imagick::GRAVITY_EAST); } else { $draw->setGravity(Imagick::GRAVITY_SOUTH); } // Get Font Metrics $tmp_metrics = ""; $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); //Original text width/height $VAR_orig_width = $tmp_metrics['textWidth']; $VAR_orig_height = $tmp_metrics['textHeight']; // Original Font Size $VAR_orig_size = $VAR_size; // Resize text font due to fit to width value if((isset($VAR_fit) && $VAR_fit == 1)) { $VAR_size = $VAR_size * ($VAR_width / $VAR_orig_width); $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; } // Resize text font due to fit to width value (only when text exceeds width) if((isset($VAR_fit) && $VAR_fit == 2)) { //Original text height //$VAR_orig_height = $tmp_metrics['textHeight']; if(!empty($tmp_metrics['textWidth']) && $tmp_metrics['textWidth'] > $VAR_width) { $VAR_size = $VAR_size * ($VAR_width / $tmp_metrics['textWidth']); } $draw->setFontSize($VAR_size); $tmp_metrics = $tmp_txt_Canvas->queryFontMetrics($draw, $VAR_txt); $VAR_new_height = $tmp_metrics['textHeight']; //$VAR_PT = $VAR_PT + ($VAR_orig_height - $VAR_new_height)/2; } //Font Size Adjustment $VAR_size_factor = $VAR_size / $VAR_orig_size; if($tmp_metrics['textWidth'] > $VAR_width) { //$VAR_fit = 1; //Adjustment for text align center $VAR_center_adjust = 0; $hook_adjust_factor = 1; //$hook_adjust_factor = $VAR_width / $VAR_orig_width; } else { //$VAR_fit = 0; $VAR_center_adjust = ($VAR_width - $tmp_metrics['textWidth'])/2; $hook_adjust_factor = 1; } // Set color and alpha for text $draw->setFillColor($text_color); $draw->setfillopacity($talpha); // Draw text on canvas $draw->annotation(0, 0, $VAR_txt); // Create Canvas for Text if((isset($VAR_fit) && $VAR_fit != 0)) { //Add Horizontal margin $tmp_txt_Canvas->newImage($VAR_width + 20, $VAR_new_height, new ImagickPixel("none")); } else { $tmp_txt_Canvas->newImage($VAR_width, $VAR_orig_height, new ImagickPixel("none")); } $tmp_txt_Canvas->drawImage($draw); // Adjustment for connector or bridge on 1st letter on some characters if($VAR_length > 1) { $f_tmp = pathinfo($layer['bridge_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']) && file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension'])) { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } else { $img_bridge1 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'1.'.$f_tmp['extension']; $img_bridge2 = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'2.'.$f_tmp['extension']; } //$img_bridge1 = $PATH_components.'pendants/bridge1.png'; $tmp_bridge1 = new Imagick($img_bridge1); //$img_bridge2 = $PATH_components.'pendants/bridge-2.png'; $tmp_bridge2 = new Imagick($img_bridge2); $tmp_bridge1->resizeImage($tmp_bridge1->getImageWidth() * $VAR_size_factor, $tmp_bridge1->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); $tmp_bridge2->resizeImage($tmp_bridge2->getImageWidth() * $VAR_size_factor, $tmp_bridge2->getImageHeight() * $VAR_size_factor, imagick::FILTER_UNDEFINED, 1); if($VAR_txt[0] == "A" || $VAR_txt[0] == "D") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 69 * $VAR_size_factor + $VAR_center_adjust, 64 * $VAR_size_factor); } else if($VAR_txt[0] == "F") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 67 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "H") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 85 * $VAR_size_factor + $VAR_center_adjust, 65 * $VAR_size_factor); } else if($VAR_txt[0] == "I") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 36 * $VAR_size_factor + $VAR_center_adjust, 71 * $VAR_size_factor); } else if($VAR_txt[0] == "O") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 51 * $VAR_size_factor + $VAR_center_adjust, 66 * $VAR_size_factor); } else if($VAR_txt[0] == "P") { $tmp_txt_Canvas->compositeImage($tmp_bridge1, imagick::COMPOSITE_DEFAULT, 70 * $VAR_size_factor + $VAR_center_adjust, 63 * $VAR_size_factor); } else if($VAR_txt[0] == "T") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 55 * $VAR_size_factor + $VAR_center_adjust, 70 * $VAR_size_factor); } else if($VAR_txt[0] == "V") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 58 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } else if($VAR_txt[0] == "W") { $tmp_txt_Canvas->compositeImage($tmp_bridge2, imagick::COMPOSITE_DEFAULT, 82 * $VAR_size_factor + $VAR_center_adjust, 68 * $VAR_size_factor); } $tmp_bridge1->clear(); $tmp_bridge2->clear(); } $f_tmp = pathinfo($layer['hook_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_hook = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_hook = $PATH_components.'pendants/hook20-ygold.png'; } else { $img_hook = $PATH_components.'pendants/hook20-silver.png'; } */ //$img_hook = $PATH_components.'pendants/hook20-silver.png'; $tmp_hook = new Imagick($img_hook); if($VAR_new_height < $VAR_orig_height) { $hookleftx = $hookleftx * $VAR_size_factor; $hooklefty = $hooklefty * $VAR_size_factor; $hookrighty = $hookrighty * $VAR_size_factor; } /*if($VAR_length > 1) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 15); } else { if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 22); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust, $hooklefty - 17); } }*/ /*if($VAR_length > 1) { if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_width - $VAR_width_last - $VAR_center_adjust, $hookrighty - 15); } else { $tmp_txt_Canvas->compositeImage($tmp_hook, imagick::COMPOSITE_DEFAULT, $hookrightx + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last - 18, $hookrighty - 28); } }*/ $tmp_hook->clear(); // Make copies of Text for layer effects $tmp_Clone1 = clone $tmp_txt_Canvas; $tmp_Clone2 = clone $tmp_txt_Canvas; $tmp_Clone3 = clone $tmp_txt_Canvas; $tmp_Clone4 = clone $tmp_txt_Canvas; $tmp_Clone5 = clone $tmp_txt_Canvas; $tmp_Clone1->modulateImage(90,60,100); $tmp_Clone2->modulateImage(60,60,100); $tmp_Clone3->modulateImage(40,60,100); $tmp_Clone4->modulateImage(150,60,100); $tmp_Clone1->resizeImage($tmp_Clone1->getImageWidth()+2, $tmp_Clone1->getImageHeight()+2, imagick::FILTER_LANCZOS, 0.8, FALSE); // Make a Canvas for Final Image $tmp_txt_Canvas->newImage($core_width, $core_height, new ImagickPixel("none")); if($VAR_length > 1) { //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 18, $hooklefty*$hook_adjust_factor - $chain_left_y); //$tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 112, $hooklefty*$hook_adjust_factor - 147); //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if((isset($VAR_fit) && $VAR_fit != 0)) { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, ($hookrightx*$hook_adjust_factor) + $VAR_width - ($VAR_width_last*$hook_adjust_factor) - $VAR_center_adjust + 28, $hookrighty*$hook_adjust_factor - $chain_right_y); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 16, $hookrighty*$hook_adjust_factor - 52); //$tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookrightx*$hook_adjust_factor + $VAR_center_adjust + $VAR_orig_width - $VAR_width_last + 50, $hookrighty*$hook_adjust_factor - 152); } } else { //Right Chain $f_tmp = pathinfo($layer['chain_right_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_right = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_right = $PATH_components.'pendants/right-chain-mid-ygold-1.png'; } else { $img_chain_right = $PATH_components.'pendants/right-chain-mid-1.png'; } */ $tmp_chain_right = new Imagick($img_chain_right); $chain_right_y = $tmp_chain_right->getImageHeight() - $VAR_PT; if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 32); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_right, imagick::COMPOSITE_DEFAULT, $hookleftx + $VAR_center_adjust + 30, $hooklefty - $chain_right_y - 27); } //Pendant $tmp_txt_Canvas->compositeImage($tmp_Clone1, imagick::COMPOSITE_DEFAULT, $VAR_PL+3, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone2, imagick::COMPOSITE_DEFAULT, $VAR_PL+2, $VAR_PT-2); $tmp_txt_Canvas->compositeImage($tmp_Clone3, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT+1); $tmp_txt_Canvas->compositeImage($tmp_Clone4, imagick::COMPOSITE_DEFAULT, $VAR_PL+1, $VAR_PT-1); $tmp_txt_Canvas->compositeImage($tmp_Clone5, imagick::COMPOSITE_DEFAULT, $VAR_PL, $VAR_PT); //$tmp_txt_Canvas->compositeImage($tmp_Clone, imagick::COMPOSITE_BLEND, $VAR_PL, $VAR_PT); //Left Chain $f_tmp = pathinfo($layer['chain_left_img']); // Path of mask image if (file_exists($PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension'])) { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$productid.'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } else { $img_chain_left = $PATH_components.$f_tmp['dirname'].'/'.$f_tmp['filename'].'-mid.'.$f_tmp['extension']; } /* if(isset($layer['metal']) && is_array($layer['metal']) && strpos($layer['metal']['name'], 'Yellow') !== false) { $img_chain_left = $PATH_components.'pendants/left-chain-mid-ygold-1.png'; } else { $img_chain_left = $PATH_components.'pendants/left-chain-mid-1.png'; } */ $tmp_chain_left = new Imagick($img_chain_left); $chain_left_y = $tmp_chain_left->getImageHeight() - $VAR_PT; /*if($VAR_txt[0] == 'M') { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y - 5); } else { $tmp_txt_Canvas->compositeImage($tmp_chain_left, imagick::COMPOSITE_DEFAULT, $hookleftx*$hook_adjust_factor + $VAR_center_adjust - 12, $hooklefty*$hook_adjust_factor - $chain_left_y); }*/ } $tmp_Clone5->clear(); $tmp_Clone4->clear(); $tmp_Clone3->clear(); $tmp_Clone2->clear(); $tmp_Clone1->clear(); $tmp_chain_left->clear(); $tmp_chain_right->clear(); return array('txt_canvas' => $tmp_txt_Canvas); } ?>
"; print_r($tmp_metrics); echo '