MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Thumbnail quality and autoscaling avatar (Zatvorena) (Mono Support )

42150 put(a) pogledan, 4 odgovor(a) 26.6.2011. 12:09:28Kreirao(la) testmmi
testmmi

testmmi

26.6.2011. 12:09:28
Hi,

is it possible out of the box, to customize the quality of thumbs in the gallery. I want to adjust a lower compression rate to get better image quality at the cost of size.

it would be nice to have a feature like auto crop for avatar images. If i upload an image with different aspect ratio the image would get distort in the avatar image box.
is there a workaround, or can i adapt my own handler to replace the current one.

thank 4 any advice and for your great product,
kind regards
Markus
Ovaj sadržaj još nije ocijenjen. 
93 Reputacija 11 Ukupno objava
khorvat

khorvat

26.6.2011. 18:18:53
Hi,

the avatar thumbs size can be changed by setting the below size in the web.config

<!-- thumbnail size: Small (72px), Medium (144 px), Large (288 px) -->
<add key="ThumbnailSize" value="Small" />

The gallery thumbs size and quality can't be changed at the moment but I'll try to find the workaround tomorrow and get back to you. As for auto crop functionality we will try to put in on our feature list for new MonoX releases.

Regards



Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
khorvat

khorvat

27.6.2011. 10:42:40
Hi,

I have made some changes to enable the image quality settings modifications, you can find the unofficial MonoX patch (4.1.2575) in the attachment.

To implement custom image quality settings you need to do the following:

1. Create your own upload handler by inheriting from MonoSoftware.MonoX.SilverlightUploadHandler
2. Override the SaveThumbnail method which will be called on every image upload in the MonoX 
- here you can create or resize uploaded images 
- existing code looks like this (MonoX version 4.1.2741):

protected virtual void SaveThumbnail(string filePath, IFileContentProvider provider)
{
    foreach (ThumbnailSizeType item in Enum.GetValues(typeof(ThumbnailSizeType)))
    {               
        Image thumbnail = ImageUtility.CreateThumbnail(filePath, (int)item);
        try
        {
            using (MemoryStream stream = new MemoryStream())
            {
                thumbnail.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);                       
                string newFilePath = ImageUtility.GetThumbnailFileName(filePath, item);
                provider.StoreFile(stream, newFilePath);
            }
        }
        catch { }
        finally
        {
            thumbnail.Dispose();
        }
    }
}

- as you can see we are pre-creating all the thumbnails and here you can use almost the same code as above but with small change, you need to call the ImageUtility.CreateThumbnail with your custom image size. If you want to change the image resize quality settings then you can use method overload that has an MonoSoftware.Core.Drawing.ImageFormatterEventArgs which exposes even more settings.

Regards
Ovaj sadržaj još nije ocijenjen. 
15993 Reputacija 2214 Ukupno objava
testmmi

testmmi

27.6.2011. 10:51:39
thanks for your fast help, i will implement it in my solution

best regards
Markus
Ovaj sadržaj još nije ocijenjen. 
93 Reputacija 11 Ukupno objava