Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:48:32+00:00 2026-05-27T19:48:32+00:00

I have a question about how should I handle image files of various sizes

  • 0

I have a question about how should I handle image files of various sizes (<1 mb upto 15mb) within a mobile application that I am developing? Currently, I am displaying the image full size using a ASHX file inside of an ASP Win Form using the ASP Image Class.

So basically what I would like to know how should I go about dealing with these sometimes vastly different image sizes.

Thanks in advance!

Update

Ok, after the very helpful comments yesterday I did some further research and I think I may have come up with a plan of action but I am still not 100%. Would copying the image to be displayed and then scaling it on the server to whatever dimensions I decide and then displaying it in the browser be a better way of “handling” images especially in an mobile browser?

Thank you all in advance for your CONSTRUCTIVE answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:48:32+00:00Added an answer on May 27, 2026 at 7:48 pm

    Ok, I found a possible solution here

    Here is the code on my ASHX file:

    Imports System.Drawing
    Imports System.Drawing.Drawing2D
    Imports System.Drawing.Imaging
    Imports System.Web
    
    Namespace WebApplication2
        ''' <summary>
        ''' Summary description for ImageDisplay
        ''' </summary>
        Public Class ImageDisplay
            Implements IHttpHandler
    
            Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest
    
                context.Response.ContentType = "image/jpeg"
    
                Dim bmp As New Bitmap(HttpContext.Current.Server.MapPath("~/Images/DSC_0165.jpg"))
    
                Dim i As Image = FixedSize(bmp, 300, 300)
                i.Save(HttpContext.Current.Server.MapPath("~/Images/DSC_0165-r.jpg"), ImageFormat.Jpeg)
                i.Dispose()
    
                context.Response.WriteFile("~/Images/DSC_0165-r.jpg")
            End Sub
    
            Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
                Get
                    Return False
                End Get
            End Property
    
            Private Shared Function FixedSize(imgPhoto As Image, Width As Integer, Height As Integer) As Image
                Dim sourceWidth As Integer = imgPhoto.Width
                Dim sourceHeight As Integer = imgPhoto.Height
                Dim sourceX As Integer = 0
                Dim sourceY As Integer = 0
                Dim destX As Integer = 0
                Dim destY As Integer = 0
    
                Dim nPercent As Single = 0
                Dim nPercentW As Single = 0
                Dim nPercentH As Single = 0
    
                nPercentW = (CSng(Width) / CSng(sourceWidth))
                nPercentH = (CSng(Height) / CSng(sourceHeight))
                If nPercentH < nPercentW Then
                    nPercent = nPercentH
                    destX = System.Convert.ToInt16((Width - (sourceWidth * nPercent)) / 2)
                Else
                    nPercent = nPercentW
                    destY = System.Convert.ToInt16((Height - (sourceHeight * nPercent)) / 2)
                End If
    
                Dim destWidth As Integer = CInt(Math.Truncate(sourceWidth * nPercent))
                Dim destHeight As Integer = CInt(Math.Truncate(sourceHeight * nPercent))
    
                Dim bmPhoto As New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
                bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution)
    
                Dim grPhoto As Graphics = Graphics.FromImage(bmPhoto)
                grPhoto.Clear(Color.White)
                grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic
    
                grPhoto.DrawImage(imgPhoto, New Rectangle(destX, destY, destWidth, destHeight), New Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel)
    
                grPhoto.Dispose()
                Return bmPhoto
            End Function
    
        End Class
    End Namespace
    

    and the code on my Default.aspx form:

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
    
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <h2>
            Welcome to ASP.NET!
        </h2>
        <p>
            To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
        </p>
    
    
        <asp:Image ID="MainImage" runat="server" ImageUrl="~/ImageDisplay.ashx" />
    
    
        <p>
            You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
                title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
        </p>
    </asp:Content>
    

    and here is how a 9mb (2848×4288) picture is displayed:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have asked a question about what I should use to create self-contained
I just discovered the what c# knowledge should I have? question and wondered about
I have a question about templates that can be used with parameters that are
I have a question about the correct way to handle errors in VBA in
Quick question about the most efficient was to handle this, I have a database
Question: Should I write my application to directly access a database Image Repository or
I have a question concerning about application testing coupled with external interfaces (REST -
I have a few questions about Core Location. 1) Should the user refuse permission
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.