• strict warning: Only variables should be passed by reference in /home/johnboker/antiyes.com/sites/all/modules/captcha/captcha.inc on line 61.
  • strict warning: Non-static method view::load() should not be called statically in /home/johnboker/antiyes.com/sites/all/modules/views/views.module on line 906.
  • strict warning: Declaration of calendar_plugin_display_page::options_submit() should be compatible with views_plugin_display_page::options_submit(&$form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/calendar/includes/calendar_plugin_display_page.inc on line 297.
  • strict warning: Declaration of calendar_plugin_display_page::options() should be compatible with views_object::options() in /home/johnboker/antiyes.com/sites/all/modules/calendar/includes/calendar_plugin_display_page.inc on line 297.
  • strict warning: Declaration of calendar_plugin_display_block::options() should be compatible with views_object::options() in /home/johnboker/antiyes.com/sites/all/modules/calendar/includes/calendar_plugin_display_block.inc on line 78.
  • strict warning: Declaration of calendar_plugin_display_attachment::options_submit() should be compatible with views_plugin_display_attachment::options_submit(&$form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/calendar/includes/calendar_plugin_display_attachment.inc on line 242.
  • strict warning: Declaration of calendar_plugin_display_attachment::options() should be compatible with views_object::options() in /home/johnboker/antiyes.com/sites/all/modules/calendar/includes/calendar_plugin_display_attachment.inc on line 242.
  • strict warning: Declaration of calendar_plugin_display_ical::options_submit() should be compatible with views_plugin_display_page::options_submit(&$form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/calendar/calendar_ical/calendar_plugin_display_ical.inc on line 217.
  • strict warning: Declaration of date_handler_field_multiple::pre_render() should be compatible with content_handler_field_multiple::pre_render($values) in /home/johnboker/antiyes.com/sites/all/modules/date/date/date_handler_field_multiple.inc on line 185.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 159.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/views/plugins/views_plugin_row.inc on line 134.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/johnboker/antiyes.com/sites/all/modules/views/plugins/views_plugin_row.inc on line 134.

AntiYes Image Resizer

ImageResizer Documentation

Resize Images

  • By Height
  • By Width
  • Absolute Size


Example


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ResizerTest._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload runat="server" ID="fupload" />
        <asp:Button runat="server" ID="btnSubmit" Text="Upload" OnClick="btnSubmit_Click" /><br />
        Width:
        <asp:TextBox runat="server" ID="txtWidth" Text="250" />
        <br />
        Quality:
        <asp:TextBox runat="server" ID="txtQuality" Text="75" />
        <br />
        <asp:Image runat="server" ID="imgOriginal" Visible="false" />
        <asp:Image runat="server" ID="imgResized" Visible="false" /><br />
    </div>
    </form>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.IO;
using AntiYes;
using System.Drawing.Imaging;
 
namespace ResizerTest
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (fupload.PostedFile.ContentLength > 0)
            {
                int width = Convert.ToInt32(txtWidth.Text);
                long quality = Convert.ToInt64(txtQuality.Text);
 
                using (ImageResizer ir = new ImageResizer(quality))
                {
                    ir.ResizeByWidth(fupload.PostedFile.InputStream, width);
                    string path = Server.MapPath("~/Upload");
                    string basename = Path.GetFileNameWithoutExtension(fupload.FileName) + "_resized";
                    string filename = ir.SaveAs(path, basename, ImageFormat.Jpeg);
                    imgResized.ImageUrl = "~/Upload/" + filename;
                }
 
                fupload.SaveAs(Server.MapPath(@"~/Upload/" + fupload.FileName));
                imgOriginal.ImageUrl = @"~/Upload/" + fupload.FileName;
                imgOriginal.Visible = true;
                imgResized.Visible = true;
            }
        }
    }
}