Jamroom Logo Jamroom 5 Core
is now Open Source!
Follow Jamroom on Twitter!

This document applies to Jamroom 2 only!
For current Jamroom 4 Documentation, visit the main Jamroom Documentation section.

Jamroom uses a PHP feature called “GD” (PHP manual entry) for resizing and manipulating images within Jamroom. Jamroom will then “cache” the re-sized images so the next time the image is called with the same dimensions, the cached image will be used. This helps speed up system performance and responsiveness.

The key to using images in Jamroom is understanding how to use the “image.php” script that is part of the Jamroom core. This script is responsible for the displaying, resizing and caching of images.

Configuration

The image.php script is mainly controlled by the parameters that are passed to it on the URL, but there are some settings in the Jamroom Config (located in the “Image Settings” section) that also come into play when using the image.php script. They are:

Jamroom Config Name Description
Enable GD Image Functions This setting allows you to turn the use of GD in manipulating the images on and off. It is highly recommended that you utilize this functionality if it is present on your server.
JPEG Quality Setting When Jamroom resizes JPG images, the output that is created is controlled via the JPEG Quality Setting. By default this is set to 85, which is a god balance of image size and quality. Setting this higher will result in larger image sizes and higher image quality, setting it lower will result in smaller image sizes and lower quality.
Anti-Aliased Enlargements When Jamroom resizes an image that is smaller then the size it is resizing it to (i.e. you have an image that is 40×40 pixels, and it is being resized to 100×100 pixels), by default GD is used to do this resizing. Sometimes this can result in images that appear “blocky”. Setting this feature to “Yes” will enable an extra function in Jamroom where the output image will be re-sampled and anti-aliased - this results in noticeably “smoother” images, at the cost of server processing. Note that it is recommended that this option only be enabled on servers with VERY fast CPU’s (over 2.4ghz), and systems with a smaller number of artists (under 100). Turning this option on on a very large system can produce an extremely high CPU load, as this functionality is very CPU intensive.
Maximum Image Width This setting allows you to specify a maximum image width. Any request to the image.php script to create an image that is larger than this setting in its width, will be set to this value instead.
Maximum Image Height This setting allows you to specify a maximum image height. Any request to the image.php script to create an image that is larger than this setting in its height, will be set to this value instead.
Skip .GIF Processing Setting this option to “yes” will make it so Jamroom “skips” the processing of GIF images. This will need to be set to “yes” if you are using animated GIF images, since the GD functions will not correctly resize GIF animated images.
Default Image Extension This setting allows you to define the image extension used by the default Jamroom images. These images are the images shown when an item specific image has not been uploaded by an artist. Note that the default images are located in the jamroom/images directory, and by default are .png images. If you would like to use different images (i.e. jpg images), first create a duplicate set of default images in the new format, place them in your jamroom/images directory, then change this setting here.

Usage

The image.php script supports several parameters that can be passed in to the image.php from the URL:

image.php?mode=(mode)&band_id=(band_id)&other_id=(number)&height=(height)&width=(width)

These parameters mean:

Parameter Name Description
mode The “mode” setting tells the image.php script the type of image that you want displayed. Valid values for the “mode” are: band_image, song_image, item_image, radio_image, calendar_image and photo_image. the mode is passed to the image.php script like so: “image.php?mode=band_image“. Note that the mode is a required parameter - the image.php will error and exit without it.
height The “height” parameter is used to tell the image.php script the height, in pixels, you want the image to be re-sized to. Note that if the number given here is greater than the “Maximum Image Height” setting (as described above), the Maximum Image Height setting will be used instead. This is used like so: “image.php?mode=band_image&height=50“. Note: if ONLY the height is given as a parameter, and no width is given, Jamroom will automatically figure out the necessary width to maintain the proper image aspect ratio.
width The “width” parameter is used to tell the image.php script the width, in pixels, you want the image to be re-sized to. Note that if the number given here is greater than the “Maximum Image Width” setting (as described above), the Maximum Image Width setting will be used instead. This is used like so: “image.php?mode=band_image&width=50“. Note: if ONLY the width is given as a parameter, and no height is given, Jamroom will automatically figure out the necessary height to maintain the proper image aspect ratio.
band_id This is the artist_id (band_id) of the artist who’s image you want to show. Note that this is required for all image.php calls.
(other)_id) The “other_id” will change, depending on the mode the image.php is working in. For example, it is NOT needed if you are showing a band_image, since the band_id is all that is needed. However, if you are showing other images (other modes), then the “(other)_id” name will need to change as needed. For example, if you are using mode=song_image, then you will need to pass in the song_id to show the proper image - i.e. mode=song_image&band_id=5&song_id=5. The following id’s are used: song_id (song_image mode), item_id (item_image mode), radio_id (radio_image mode), event_id (calendar_image mode) and image_id (photo_image mode).

Using the image.php script in your Artist themes or other Jamroom output templates (i.e. ranking, charting, searching, etc.) is fairly easy to do:

Using the image.php script in the Jamroom Artist Themes

If you are modifying or creating a Jamroom Artist Theme, then there are 2 different types of Theme Variables that you can use in your themes for utilizing the image.php. For each “type” of image (i.e. band image), there are 2 corresponding Artist Theme variables - i.e. {BAND_IMAGE} and {BAND_IMAGE_GD}. It is highly recommended that you only use the {BAND_IMAGE} (i.e. “non _GD”) variable in your theme templates (this holds true for the other types as well - i.e. use the {SONG_IMAGE} variable instead of the {SONG_IMAGE_GD} variable). By using the non _GD version of the variables, you have more control in your templates over how the output images look. Here is the main difference (using {BAND_IMAGE} and {BAND_IMAGE_GD} as a comparison - the same holds true for all other image types in the Artist Themes):

Variable Pros and Cons
{BAND_IMAGE} By using the non _GD variable, you have full control over the width and height of the image. You can use different size images for each type in your theme.
{BAND_IMAGE_GD} This variable is easier to use, in that no width and height are needed - this variable gets its width and height settings from the theme’s config.cfg.php file. If all of the images in your Artist Theme templates (of each type) are always going to be the same size, then this variable can be used. It is HIGHLY recommended however, that you avoid using this variable if creating new templates and themes, since it can easily “stretch” images to fit into the required width and height, which may not be a desirable effect.

To use these variables in your Artist Theme templates, use them like this:

<img src="{BAND_IMAGE}&width=200" width="200" border="0" />

This code would create an artist image that is 200 pixels wide, and is the correct height to maintain the proper aspect ratio (i.e. if the image was originally 600×400, the resulting cached image would be 300×200).

Using the image.php script in your Smarty templates

Using the image.php script in other areas of your Jamroom (i.e. ranking, newsearch, newchart, etc.) is also very easy (and very much like their use in the Artist templates). You can use the image call like so:

Example Artist Image resized to 200 pixel width:

<img src="{$JAMROOM_URL}/image.php?mode=band_image&band_id={$BAND_ID}&width=200" width="200" border="0" />

Example Song Image resized to 64 pixels in both height and width:

<img src="{$JAMROOM_URL}/image.php?mode=song_image&band_id={$BAND_ID}&song_id={$SONG_ID}&width=64&height=64" width="64" height="64" border="0" />

As you can see, you can pass in the height and width seperately, or together. Note too how the HTML height and width is always given as well. This ensures that if GD does not function properly, then the image will be resized by the viewers browser.

Conclusion

Using the information provided above, it should be fairly easy to get the image.php script to manipulate any image in Jamroom to your custom needs.

Solutions Products Support Community Company
Social Media Platform
Social Networking Software
Musician Website Manager
Community Builder
Jamroom 5
Jamroom 5 Modules
Jamroom Marketplace
Support Forum
Documentation
Support Center
Contact Support
Community Forum
Member Sites
Developers
About Us
Contact Us
Privacy Policy
©2003 - 2024 The Jamroom Network