Archive for Settembre 26th, 2007

Crear un WSDL

Settembre 26th, 2007

Description: Explicación de como obtener un WDSL de un servicio web desplegado.

Link: http://www.codekeep.net/snippets/7eaea489-dea1-4be7-aa6b-0dadb08f1814.aspx

http://localhost:2802/Service1.asmx?wsdl

Para obtener el wsdl de un servicio basta con lanzarlo
y añadir a la url de invocacion "?wsdl" al final.

El Visual Studio cuando añade una referencia Web,
en realidad lo que hace es añadir este sufijo para
obtener el wdsl, y ejecutar internamente el wdsl.exe
que creará la clase proxy cliente para invocar al
servicio.

TestSnippet

Settembre 26th, 2007

Book Review: The Designer's Apprentice

Settembre 26th, 2007

One of the challenges facing computer artists is productivity, especially with repetitive tasks. Fortunately, this book shows you how to automate your workflow by using several types of scripting, including: AppleScript, JavaScript, VBScript, data-driven publishing and more. By Nathan Segal. 0926

Create image’s thumbnail

Settembre 26th, 2007

Description: Create a thumbnail from an image and save the thumbnail into it’s original image file format

Link: http://www.codekeep.net/snippets/52492b12-d17b-4dcd-acdf-c2c9fcb09f68.aspx

public bool MakeThumbnail(string thumb, string img, int width, int height, bool keepOriginalRatio)
    {
        System.Drawing.Image fullSizeImg;
        try
        {
            fullSizeImg = new System.Drawing.Bitmap(img);
        }
        catch (Exception ex)
        {
            return false;
        }

        if ((fullSizeImg.Width <= width) && (fullSizeImg.Height <= height))
        {
            //Smaller or same size as thumbnail so no need to do anything special
            try
            {
                fullSizeImg.Save(thumb);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        else
        {
            if (keepOriginalRatio)
            {
                if (width <= 0)
                {
                    width = height * fullSizeImg.Width / fullSizeImg.Height;
                }
                else if (height <= 0)
                {
                    height = width * fullSizeImg.Height / fullSizeImg.Width;
                }
                else
                {
                    float TargetRatio = width / height;
                    float CurrentRatio = fullSizeImg.Width / fullSizeImg.Height;

                    if (CurrentRatio > TargetRatio) //We'll scale height
                    { height = width / Convert.ToInt16(CurrentRatio); }
                    else // We'll scale width
                    { width = height * Convert.ToInt16(CurrentRatio); }
                }
            }

            System.Drawing.Image thumbNailImg = new System.Drawing.Bitmap(fullSizeImg, width, height);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumbNailImg);

            g.FillRectangle(System.Drawing.Brushes.White, 0, 0, width, height);
            g.DrawImage(fullSizeImg, 0, 0, width, height);

            try
            {
                thumbNailImg.Save(thumb, fullSizeImg.RawFormat);
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        return false;
    }