magento: Resize image during upload to desired dimensions - magento

I want to resize product images before upload them by using values through text boxes.
eg:
user browse image and then give width(px) in one text and height(px) in another textbox click on apply and now this size is apply on image.
then user upload image.
can any one tell me or guide me to resource so i can get this functionality.
i already added both text box with button on product image upload grid.

What is the point? Magento spares you from any of that fooling around with images. You upload them in whatever size you want hen it creates and caches the sizes it needs on the fly. What your trying to achieve is a leap backwards.

Please use this code to resize your image
$imageUrl = "http://localhost/";
$imageResized = Mage::getBaseDir('media').DS."catalog/category/resized";
$imageObj = new Varien_Image($imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(false);
$imageObj->keepTransparency(True);
$imageObj->setImageBackgroundColor(false);
$imageObj->backgroundColor(false);
$imageObj->quality(100);
$imageObj->setWatermarkImageOpacity(0);
$imageObj->resize(120, 120);
$imageObj->save($imageResized);

I think you have to look at this controller.
Mage_Adminhtml_Catalog_Product_GalleryController
You will need to rewrite this controller. Some how make the width and height values arrive to the action. And than apply re-sizing to the image.
HTH

Related

Parsys on top of an image

There is requirement where parsys should be added on top of an image. It is like a background image with the provision of parsys so that other components can be dragged and dropped on top of it. I am using html5smartimage for image component. But, no clue yet on how I can get the parsys on top of the image. Please help if you find any ideas. Thanks.
is the image authorable? If so, how do you intend to provide click-area for the authors to change the image vs edit items in the parsys.
If the image isn't authorable, just target the CSS for your parsys and set the image.
If the image is authorable, in edit mode you want the image to be distinct from the parsys and have separate clickable areas. Then in preview/disabled modes you would generate the actually desired markup & CSS to position the parsys content over the background image.

Magento: Detailed Image on Mouse-over for Product Attribute

I would like to show a detailed image on mouseover for each of our options.
This is exactly what i am after:
http://www.potterybarn.com.au/textured-solid-pillow-cover
Any idea on how to do that? Or is there a plugin available for that?
Detailed image is usually called product zoom function and it's present in most of magento themes including default ones. It shows original image on zoom function and smaller version of the same image by default.
Images for options function is called color swatch, most of the modules aren't free. But the recent magento 1.9.1 has this feature for free in their new default theme called rwd. There are both color swatch and product image zoom features. You can look how they've done it and extend their solution if you need something more
The easiest way to achieve option image itself on hover would be to use image of resolution you need to have on hover in your configurable product. Then change html of configurable swatch options file. Currently it shows just one image, you can add the same image wrapped in some block. Then change the size of one image to be small, hide block hide big one and show it on hover via css/js.
File with code for swatches: app/design/frontend/rwd/default/template/configurableswatches/catalog/product/view/type/options/configurable/swatches.phtml
/skin/frontend/rwd/default/js/configurableswatches/swatches-list.js
and change line no: 52 "click" to "mouseover"
Then check, if correct please vote me.
Thanks.

TinyMCE prevent image resizing

I am adding an image to a TinyMCE editor using:
var params = {
src: filename,
title: "Attached image: " + filename,
width: 500
};
ed.execCommand("mceInsertContent", false, ed.dom.createHTML("img", params));
This insert the image correctly in the editor. However, when the user clicks on the image he has the ability of resizing it.
I would like to know if there is a way to:
Prevent the user to resize only in one direction (i.e. how do I keep a fixed aspect ratio for the image)
Completely prevent the user to resize the image
I found a (partial) answer, so I thought I will share it here.
Adding
'object_resizing' : false
In the editor config prevents the resizing.
Note that this is a feature of Mozilla only (e.g. Google Chrome does not allow you to resize the image).
I am still looking for a way of keeping aspect ratio in real time, but I do not know if that is really possible.
You can simply add this little plugin to tinyMCE, I used it and it works very well!
Here's the documentation: Link
You would need to implement a resize handler (for example a jQuery handler).
It might be helpfull to add attributes to your images to save its dimensions or to use one single setting holding the aspect ratio. For this you will adjust the tinymce configuration setting valid_elements to allow those attributes for images - otherwise tinymce would strip them out.
When resize gets fired you grab the new dimensions and adjust the dimensions according to the aspect ratio - eigther adjust using the new width or new heigth (the other value is needs to get corrected).
Example: images have an attribute aspectratio holding the aspect ration
You may place this code in thetinymce setup configuration parameter
setup : function(ed) {
ed.onInit.add(function(ed) {
$(ed.getBody()).find('img').resize( function(event){
$(event.target).css('width', parseInt ( event.target.width * this.aspectratio) );
});
});
}
Update:
I have created a tinymce fiddle to show an example to use with IE.

Large Image Centering

I get from the server image 800X800 in jpg format and i need to display it in center of the WP7 screen. I need to display like example in this url
http://imageshack.us/photo/my-images/152/examplea.jpg/
I prefer to do this without cropping of image if it possible, because i get new image always in start of application. I tried with stretch, rectangle geometry.
I write this without code example, because this is only insert a image.
Sorry for my bad English.
Try like this in Xaml
Image name="Image" width = 800 height = 1000 stretch = fill Margin="-215,-120,-255,-184"
Then set the source

Magento - Product Page - Load image in main area

In product page, I have one main image and 4 other images coming as thumbnail. I have coded now so that if any of 4 image is clicked, it will be loaded in main image area.
Now the issue comes of size. If I put via resize, each image is resized. If I don't call resize(), then it will show original size without zoom in case of big image.
Can I have something where I find the width and height of thumb nail image too. Based on this, I can code in media.phtml to call Resize() or not.
Can anyone help please?
Jeff

Resources