Automatically image resize when attach new images
  • Is that possible when I attach a new image to resize this image using a predefined template ?

    For example I choose to upload an image with 1600X1200 image size. After selection the image, using a predefined template automatically resize/crop this image to 640X480pixels.

    You can find this feature to other CMS like Drupal or Joomal and I think is very useful.

    Regards,
    George
  • 19 Comments sorted by
  • You can:
    - set the default resize width/height for all your article attached images
    from the menu->system preferences (see "Image Resizing Width" and "Image
    Resizing Height" fields)
    - set the width/height for each image when embedding an image in the text
    - set the widh/height through the template language:
    {{ url options="image <image_no> width <width> height <height>" }}
    (see http://en.flossmanuals.net/Campsite/Miscelaneous - "Displaying the
    URL")

    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Thu, Sep 23, 2010 at 10:46 AM, sdancer75 <
    campsite-support@lists.sourcefabric.org> wrote:

    > Is that possible when I attach a new image to resize this image using a
    > predefined template ?
    >
    > For example I choose to upload an image with 1600X1200 image size. After
    > selection the image, using a predefined template automatically resize/crop
    > this image to 640X480pixels.
    >
    > You can find this feature to other CMS like Drupal or Joomal and I think is
    > very useful.
    >
    > Regards,
    > George
    >

  • Dear Rus,

    Yes that's true and I saw it. But this is just a visual trick since the image size itself does not physically changes ( in constrast with the thumnails for the image preview in the image gallery) and of course you dont earn anything at the speed/space level. Browsers have to load the huge image in their memory and then generate a smaller version according to the instruction they took from the HTML code and this is done, every time the page is requested.

    Of course, this not a big deal if you just need to view a sigle article. But think the case that someone uses only one but huge image (say 1600X1200) for each article and want to preview this image in the home page like the Custodian sample, you can easily understand that the response time will be too high.

    Of course there are solutions ie to create 2 versios of the same images one big and one small for the preview, but this is not in case for article managers, or the authros that don't know anything about image editing, resolution etc.

    Campsite should have such a mechanism to optimize as more as it can the image files with a simple and clean way.

    Regards,
    George
  • Images are resized and saved locally - this is transparent to the user;
    Campsite serves the resized version of the image (e.g. 600x400) - not the
    original file (e.g. 1800x1200).

    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Thu, Sep 23, 2010 at 2:00 PM, sdancer75 <
    campsite-support@lists.sourcefabric.org> wrote:

    > Dear Rus,
    >
    > Yes that's true and I saw it. But this is just a visual trick since the
    > image size itself does not physically changes ( in constrast with the
    > thumnails for the image preview in the image gallery) and of course you dont
    > earn anything at the speed/space level. Browsers have to load the huge image
    > in their memory and then generate a smaller version according to the
    > instruction they took from the HTML code and this is done, every time the
    > page is requested.
    >
    > Of course, this not a big deal if you just need to view a sigle article.
    > But think the case that someone uses only one but huge image (say 1600X1200)
    > for each article and want to preview this image in the home page like the
    > Custodian sample, you can easily understand that the response time will be
    > too high.
    >
    > Of course there are solutions ie to create 2 versios of the same images one
    > big and one small for the preview, but this is not in case for article
    > managers, or the authros that don't know anything about image editing,
    > resolution etc.
    >
    > Campsite should have such a mechanism to optimize as more as it can the
    > image files with a simple and clean way.
    >
    > Regards,
    > George
    >
    >

  • >>Images are resized and saved locally - this is transparent to the user;
    >>Campsite serves the resized version of the image (e.g. 600x400) - not the
    >>original file (e.g. 1800x1200).

    Dear Mugur Rus,

    We have talked about this at the past. But this, is not working at least in my installation. I use the latest version of the campsite and I changed the system configuration according to the following options :

    Editor Settings:
    Image Resizing Ratio: 100%
    Image Resizing Width: 640 pixels
    Image Resizing Height: blank (just to follow the aspect ration respecting the image width)

    I attach a new image with a 1200X1200 pixel resolution. I use this image inside my article as well as a preview in the teaser mode, using the original sample code that is come with the package.

    I found out that, there is no image resize at the attached image. The file size inside the images folder, have the original size and the original resolution. Beside, you can easily understand that, because the image downloading when you preview the article is slow.

    Am I doing something wrong here ?

    PS:Inside the images folder, there is a folder with the name thumbnails. There is no new images here from my articles.

    Regards,
  • Please check if the following path exists in the Campsite directory:

    images/image_cache/derivates

    Inside it you should find directories with names like "350x0", "350x270",
    depending on your image resize settings.

    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Mon, Oct 18, 2010 at 2:01 PM, sdancer75 <
    campsite-support@lists.sourcefabric.org> wrote:

    > >>Images are resized and saved locally - this is transparent to the
    > user;
    > >>Campsite serves the resized version of the image (e.g. 600x400) - not the
    > >>original file (e.g. 1800x1200).
    >
    > Dear Mugur Rus,
    >
    > We have talked about this at the past. But this, is not working at least in
    > my installation. I use the latest version of the campsite and I changed the
    > system configuration according to the following options :
    >
    > Editor Settings:
    > Image Resizing Ratio: 100%
    > Image Resizing Width: 640 pixels
    > Image Resizing Height: blank (just to follow the aspect ration respecting
    > the image width)
    >
    > I attach a new image with a 1200X1200 pixel resolution. I use this image
    > inside my article as well as a preview in the teaser mode, using the
    > original sample code that is come with the package.
    >
    > I found out that, there is no image resize at the attached image. The file
    > size inside the images folder, have the original size and the original
    > resolution. Beside, you can easily understand that, because the image
    > downloading when you preview the article is slow.
    >
    > Am I doing something wrong here ?
    >
    > PS:Inside the images folder, there is a folder with the name thumbnails.
    > There is no new images here from my articles.
    >
    > Regards,
    >

  • no there is no such directory either in my local installation or in my public installation.
  • > Editor Settings:
    > Image Resizing Ratio: 100%
    > Image Resizing Width: 640 pixels
    There is the problem: if set, image resizing ratio is used regardless of the
    other resizing options. So just set the image resizing ratio to 0.

    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Mon, Oct 18, 2010 at 2:01 PM, sdancer75 <
    campsite-support@lists.sourcefabric.org> wrote:

    > >>Images are resized and saved locally - this is transparent to the
    > user;
    > >>Campsite serves the resized version of the image (e.g. 600x400) - not the
    > >>original file (e.g. 1800x1200).
    >
    > Dear Mugur Rus,
    >
    > We have talked about this at the past. But this, is not working at least in
    > my installation. I use the latest version of the campsite and I changed the
    > system configuration according to the following options :
    >
    > Editor Settings:
    > Image Resizing Ratio: 100%
    > Image Resizing Width: 640 pixels
    > Image Resizing Height: blank (just to follow the aspect ration respecting
    > the image width)
    >
    > I attach a new image with a 1200X1200 pixel resolution. I use this image
    > inside my article as well as a preview in the teaser mode, using the
    > original sample code that is come with the package.
    >
    > I found out that, there is no image resize at the attached image. The file
    > size inside the images folder, have the original size and the original
    > resolution. Beside, you can easily understand that, because the image
    > downloading when you preview the article is slow.
    >
    > Am I doing something wrong here ?
    >
    > PS:Inside the images folder, there is a folder with the name thumbnails.
    > There is no new images here from my articles.
    >
    > Regards,
    >

  • Hi,

    Yes I thought of that, but it can not accept values smaller than 1.
    If I set it 1 then I get an 1 pixel wide picture.

  • Hi,

    Sorry for just popped up onto this discussion. Please read this HowTo I wrote when implementing this:
    http://wiki.sourcefabric.org/display/CS/Image+Resizing+and+Z ooming

    From there... "If you set Ratio to 100% and either one or both Width/Height to a smaller size than the original, then image won't be resized by Ratio but Width/Height."

    Hope it helps,
  • Hi Holman,

    I didn't read this article before, but as a programmer I thought it would work like this way.

    Its sure that it does not work at least in my installation. I used ratio 100% and width 630 leaving the height blank.

    I attached a new image with size 970X40 and the only change in the image directory (i deleted all files before expect the directory structure which are the folders "plugin_blog" and "thumbnails") is the uploaded file with the internal name "cms-image-000000123.jpg" which it still has the original width/height, and the correspondence thumbnail inside the "thumbnails" folder which has 64X2 dimensions and is used in the "Attach Existing Image" option.

    I use xampp 1.7.3 in my machine and i didn't have time to search inside the code about this, but maybe the problem is the appropriate image library from php ? Using phpinfo () the version of the GD reports "bundled (2.0.34 compatible)"

    I attach my phpinfo() for debug reasons.

    Regards,
    George
  • It doesn't work like that. When you upload an image via Content -> Image Archive, Campsite only generates 1 thumbnail + the original image.

    Image resizing by ratio and height/width only works for images attached to an article via the rich text editor in the article edit screen. That's why those settings are under System Preferences::Editor Settings.

    Those values there are to set global values, but you still can set individual values per picture when inserting the image via the rich text editor's image plugin, and in order to do that the image must be already stored in the image archive and attached to the article.

    Hope it is much clear now, if not... don't hesitate to keep asking Wink

    p.s.: taking notes from your input to extend this feature in the future.
  • Ive got exactly the same problem but i have the derivatives folder on the server

    three folders
    20
    330x0
    40

    their is only 1 picture in the 330x0 folder

    all the rest of the pictures are in the root images directory at full size

    I have also noticed that if i just drag them to my desktop they are now called get_img.jpg when i did this with a previous installation it was something like cms_image_000000001.jpg

    The thumbnail still appears in the thumbnail folder as a small 2k file named cms_thumb_000000001.jpg

    I have built my resize into the template as i cant change the system preference file as it keeps giving me an error which ive emailed over to you
  • Holman

    I think I tried with all possible ways. I don't see any new file in my images list expect the original and the correspodence thumbnail.

    Despite of that, when I click on the image and select "save as" in the user mode and I save it, the image dimensions are correct.The html code reports that.

    <img src=" /get_img?NrArticle=138&amp;NrImage=200&amp;ImageWidt h=630 " border="0"/>

    Does this conversion takes place in real time ?

    Here what i do.

    1. I create a new article
    2. I click on the option "attach new image"
    3. I select a *.jpg image from my local folder witn 1600X1200pixels size
    4. Save the image and it appears in the attached list in my article
    5. In my article body, I click on icon campsiteimage
    6. From the list I select the only one image i attached before
    7. I click "save all and close"

    My system preferences are the mentioned before which is

    ration 100%
    width 630
    height blank


    Regards,
    George
  • Hi George,

    That's something important I forgot to tell you. These image
    conversion happens on the fly, no image is stored at file system. I
    still have to check out the code because I don't remember whether I
    implemented a cache system for this (which I should) or not. The
    original purpose of this was to allow to the user to use a single
    image across the website in any size without storing all those
    derivated from the original file in the file system.

    As I said yesterday, from all this discussion and some others requests
    we have had from different users, it is clear now we should extend the
    feature and make it more flexible.

    Cheers,


    On Thu, Oct 21, 2010 at 8:46 AM, sdancer75
    <campsite-support@lists.sourcefabric.org> wrote:
    >
    > Holman
    >
    > I think I tried with all possible ways. I don't see any new file in my images list expect the original and the correspodence thumbnail.
    >
    > Despite of that, when I click on the image and select "save as" in the user mode and I save it, the image dimensions are correct.The html code reports that.
    >
    > <img src=" /get_img?NrArticle=138&amp;NrImage=200&amp;ImageWidt h=630 " border="0"/>
    >
    > Does this conversion takes place in real time ?
    >
    > Here what i do.
    >
    > 1. I create a new article
    > 2. I click on the option "attach new image"
    > 3. I select a *.jpg image from my local folder witn 1600X1200pixels size
    > 4. Save the image and it appears in the attached list in my article
    > 5. In my article body, I click on icon campsiteimage
    > 6. From the list I select the only one image i attached before
    > 7. I click "save all and close"
    >
    > My system preferences are the mentioned before which is
    >
    > ration 100%
    > width 630
    > height blank
    >
    >
    > Regards,
    > George
    >


    --
    Holman Romero
    Senior Software Engineer, Sourcefabric
    holman.romero@sourcefabric.org

    Salvátorská 10
    110 00 Praha 1, Czech Republic
    +420 608910633

    http://www.sourcefabric.org
  • "<img src=" /get_img?NrArticle=138&amp;NrImage=200&amp;ImageWidt h=630 "
    border="0"/>
    Does this conversion takes place in real time ?"
    Yes, the resized image file will not be generated until the first request
    for the image. So you need to go to the frontend and view the article page.

    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Thu, Oct 21, 2010 at 9:46 AM, sdancer75 <
    campsite-support@lists.sourcefabric.org> wrote:

    > Holman
    >
    > I think I tried with all possible ways. I don't see any new file in my
    > images list expect the original and the correspodence thumbnail.
    >
    > Despite of that, when I click on the image and select "save as" in the user
    > mode and I save it, the image dimensions are correct.The html code reports
    > that.
    >
    > <img src=" /get_img?NrArticle=138&amp; NrImage=200&amp;ImageWidt h=630 "
    > border="0"/>
    >
    > Does this conversion takes place in real time ?
    >
    > Here what i do.
    >
    > 1. I create a new article
    > 2. I click on the option "attach new image"
    > 3. I select a *.jpg image from my local folder witn 1600X1200pixels size
    > 4. Save the image and it appears in the attached list in my article
    > 5. In my article body, I click on icon campsiteimage
    > 6. From the list I select the only one image i attached before
    > 7. I click "save all and close"
    >
    > My system preferences are the mentioned before which is
    >
    > ration 100%
    > width 630
    > height blank
    >
    >
    > Regards,
    > George
    >

  • Hi,

    Thank you for clarifying this. Now all these posts are making sense. I didn't checked the front end before today since I just waitted to see files to be created in my image folder.

    The
    original purpose of this was to allow to the user to use a single
    image across the website in any size without storing all those
    derivated from the original file in the file system.


    That was a good idea and you should keep it its very useful, but I think that you have to add also an extra system preference that it should convert the original image (at the uploading procedure) to the highest optimized one and use this as a reference image ( I dont want to upload my original huge photos directly from my camera, since I will never use such high resolutions).

    Now I just use the XnView tool to automatically convert my huge images to the desired size and then I upload them in my campsite since without this step is just a waste of space. That's an extra step that I would be very happy to avoid sometime in the future.


    After many many replies its now all got the right position. Thank you for your help.

    Best Regards,
    George
  • Hi again

    by system pref file is

    ratio 100
    width 600
    height 600

    i want the picture to be a maximum of 600 width or 600 height whichever is the biggest

    when i change my pref file i get an error

    Campsite has encountered a problem.

    Please take a minute to send us an email.

    Simply copy and paste the error report below and send it to: campsite-support@campware.org.

    Thank you.

    Error Report
    Error ID: 2:Campsite:3.4.2:SystemPref.php:151
    Error String: chmod() [function.chmod]: Operation not permitted
    Time: Thu, 21 Oct 2010 13:57:26 +0000
    Backtrace:

    camp_report_bug() called at [Grin
    chmod() called at [/home/fdimagaz/public_html/classes/SystemPref.php:151]
    SystemPref::StoreSystemPrefsInCache() called at [/home/fdimagaz/public_html/classes/SystemPref.php:108]
    SystemPref::Set() called at [/home/fdimagaz/public_html/admin-files/system_pref/do_edit. php:145]
    require_once() called at [/home/fdimagaz/public_html/admin.php:164]
  • Hi

    The problem i had with system prefs has been resolved but i still get the large file sizes

    I have also just set up a completely new site with a clean install of 3.4.3 and i get the same problem with image sizes not being changed

    has anyone got any other suggestions
  • Check whether you embedded your images in the text. If not the system
    preferences won't help you. Check this post on how to resize images:

    http://forum.sourcefabric.org/index.php/t/3186/
    <http://forum.sourcefabric.org/index.php/t/3186/>
    Mugur Rus
    Senior Software Developer, Sourcefabric
    mugur.rus@sourcefabric.org

    Cluj-Napoca, Romania
    +40 (0)720 528408
    Skype: mugur_rus

    http://www.sourcefabric.org
    http://www.twitter.com/Sourcefabric


    On Wed, Nov 3, 2010 at 5:54 PM, mark casson <
    campsite-support@lists.sourcefabric.org> wrote:

    > Hi
    >
    > The problem i had with system prefs has been resolved but i still get the
    > large file sizes
    >
    > I have also just set up a completely new site with a clean install of 3.4.3
    > and i get the same problem with image sizes not being changed
    >
    > has anyone got any other suggestions
    >