Announcement

Collapse
No announcement yet.

Automatic image resizing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Automatic image resizing

    Still very new to actinic and working my way through the trial and documentation.

    I find it very strange that actinic doesn't offer automatic resizing of product images and thumbnail creation inside the actinic programme. Especially since this is a windows programme, and other similar software has this has standard. The average end user client wouldn't expect or generally have the software to create the images outside of the package.

    Looking at the other posts I see there are lots of 'fixes' and updates. It also seems to require PHP installed on the clients PC to be able to do the resizing. Is that correct?

    Could someone point me in the direction of the most up to date way of doing image resizing so I don't end up looking at out of date methods?

    #2
    Have you looked in the KB before posting? I'm pretty sure Norman provide some code to do just what you want, you don't have to install php, it is already installed inside of actinic to run on the desktop.

    Comment


      #3
      Hi Lee

      I've spent ages looking in the articles/forums and there seem quite a number of different posts, then updates to posts, then bug fixes and suggestions to existing posts etc. I found myself in a bit of a muddle trying to find the correct one, then finding in another post that I had to applying fixes etc.

      I was wondering if there was an up to date, complete/recommeded method etc. as I've been going around in circles?

      Comment


        #4
        The articles in the KB don't suffer that fate, the finished articles tend to go in there once the forum has sorted them all out. Have you looked in the KB? The AUG is the same. Both contain completed solutions plus instructions. The forum is just where things get thrashed out.

        Comment


          #5
          Cheers

          I found this one which I assume is the one you are referring to:

          http://community.actinic.com/showthread.php?t=45409

          Seems to work well for making the product image.

          Do you know if it is possible to resize the image that is placed into the extended product details? I'd like to put a max size on that because some clients are going to use huge image files that need resizing?
          Last edited by KB2; 22-Mar-2010, 12:12 PM. Reason: Updating kb links

          Comment


            #6
            This (untested) should work for the Extended Info Image. Use the KB article for guidance and create a variable ExtendedInfoImageScaledWidth as well.
            Code:
            <actinic:block php="true" >
            // START Create a thumbnail image x_ProductImageFileName
            $sOriginalImageName = str_replace('\\','/', '<actinic:variable name="ExtendedInfoImage" encoding="perl" selectable="false" />');
            $nScaledWidth = <actinic:variable name="ExtendedInfoImageScaledWidth" encoding="perl" selectable="false" />;
            $sThumbImageName = 'Thumbnails/x_' . basename($sOriginalImageName);
            if (file_exists($sThumbImageName)) {
            
            echo "<img src=\"$sThumbImageName\"  border=\"0\"";
            echo " alt=\"<actinic:variable name="ProductName" encoding="strip"/>\" />";
            } else {
            $image = @imagecreatefromjpeg($sOriginalImageName); /* Attempt to open */
            if (!$image)
            { /* See if it failed */
            echo "<br><font color=red>Thumbnail creation error opening: $sOriginalImageName </font>";
            }
            else
            {
            // Get new dimensions
            $width = imagesx($image);
            $height = imagesy($image);
            $t_width = $nScaledWidth;
            $t_height = round($height * ($t_width / $width));
            // Resample
            $thumbimage = imagecreatetruecolor($t_width, $t_height);
            imagecopyresampled($thumbimage, $image, 0, 0, 0, 0, $t_width, $t_height, $width, $height);
            if ( ! imagejpeg($thumbimage, $sThumbImageName) )
            {
            echo "<font color=red>Thumbnail image creation failed: $sThumbImageName </font><br>";
            }
            else
            {
            echo "<img src=\"$sThumbImageName\" width=\"$t_width\" height=\"$t_height\" border=\"0\"";
            echo " alt=\"<actinic:variable name="ProductName" encoding="strip"/>\" />";
            }
            }
            }
            // END Create a thumbnail image x_ProductImageFileName
            </actinic:block>
            Note that this may only (due to an Actinic bug) work if the Extended Info image is directly in your site folder.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Fab! I'll give it a go.

              Comment

              Working...
              X