errore con resize di un'immagine

erlupacchiotto

Nuovo Utente
5 Gen 2004
23
0
0
51
Roma
www.erlupacchiotto.com
sto' utilizzando uno script aspx che ridimensiona sul server le immagini prima di caricarle sul client, al fine di ottimizzare i tempi di caricamento della pagina

Il problema che mi si pone e' che funziona SOLO SE
Altezza < Larghezza
anche di un solo pixel

come mai ?
guarda questa pagina
http://www.erlupacchiotto.com/prova/Foto/FotoRedim.html
solo la foto di dx viene caricata, quella al centro invece no

grazie a tutti anticipatamente

-------redim.html----------
PROVA FOTO 90*90
<img src="resize.aspx?src=Foto4.jpg&w=150&h=150">
PROVA FOTO 90*89
<img src="resize.aspx?src=Foto5.jpg&w=150&h=150">

-------resize.aspx----------
<%@ import namespace="System" %>
<%@ import namespace="System.Drawing" %>
<%@ import namespace="System.Drawing.Imaging" %>
<%@ import namespace="System.IO" %>

<script runat="server">

Function NewthumbSize(currentwidth, currentheight)


' Calculate the Size of the New image




dim k,a,b,c,d as Double

k=currentwidth/currentheight

a=currentwidth
b=currentheight
c=Request.QueryString("h")
d=Request.QueryString("w")



'if (k<=1 and currentheight>=c) then
'a=c*k
'b=c
'end if

if (k>1) then

a=d
b=d/k

else

a=c*k
b=c

end if




dim NewSize as New Size(a, b)








return NewSize

End Function


Sub sendFile()

' create New image and bitmap objects. Load the image file and put into a resized bitmap.
dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(request("src")))
'dim g as System.Drawing.Image = System.Drawing.Image.FromFile(request("src"))






' initialise the web object
'Dim webC As New System.Net.WebClient()

' set the URL
'Dim strFilename as string

'if Request.QueryString("src")="" then
' strFilename="http://127.0.0.1/chiave.jpg"
'else
' strFilename="http://127.0.0.1/thumbaspx/"&Request.QueryString("src")
'end if

' create a bitmap based on the image from the URL
'Dim g = New System.Drawing.Bitmap(webC.OpenRead(strFilename))










dim thisFormat=g.rawformat

dim thumbSize as New size
thumbSize=NewthumbSize(g.width,g.height)

dim imgOutput as New Bitmap(g, thumbSize.width, thumbSize.height)

' Set the contenttype

'if thisformat.equals(system.drawing.imaging.imageformat.Gif) then
'response.contenttype="image/gif"
'else
response.contenttype="image/jpeg"
'end if



' send the resized image to the viewer
imgOutput.save(response.outputstream, thisformat) ' output to the user

' tidy up
g.dispose()
imgOutput.dispose()

end sub

Sub sendError()

' if no height, width, src then output "error"
dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)
dim g as graphics = graphics.fromimage(imgOutput)
'create a New graphic object from the above bmp
g.clear(color.yellow) ' blank the image
g.drawString("ERRORE!", New font("verdana",14,fontstyle.bold),systembrushes.windowtext,new pointF(2,2))

' Set the contenttype
response.contenttype="image/jpeg"

' send the resized image to the viewer
imgOutput.save(response.outputstream, imageformat.jpeg) ' output to the user

' tidy up
g.dispose()
imgOutput.dispose()


end sub


</script>



<%


' make sure Nothing has gone to the client
response.clear


if request("src")="" then

call sendError()

else

if file.exists(server.mappath(request("src"))) then
call sendFile()
else
call sendError()
end if

end if


response.end

%>
 
Discussioni simili
Autore Titolo Forum Risposte Data
Jensen Errore di sintassi con DELETE PHP 3
P errore 404 con javascript Javascript 2
R Navigare sito con cURL, mi restituisce errore PHP 0
L File CSV con app inventor da errore Sviluppo app per Android 2
I Errore 80040220 nella newsletter con paginazione Classic ASP 0
MarcoGrazia [PHP] Download di file con errore all'interno. PHP 1
Tommy03 Errore invio email con PHP PHP 1
Max 1 Errore driver con lettore di smart card Hardware 6
A [PHP] errore 404 e invio mai path pagina con link interrotto PHP 2
3_g errore con mysql insert in PDO PHP 29
M [MySql - VB6 sp6] Problema connessione db con alcuni pc (errore Lost connection to MySQL server...). MySQL 1
M [MySQL] Solito errore #1064 con poca comprensione MySQL 14
L [PHP] upload con errore PHP 2
auritidesign Errore con mysqli_fetch_array PHP 3
C [MySQL] errore nell'importazione tabella con file csv MySQL 0
6 Errore pubblicazione sito con Muse Webdesign e Grafica 0
romeocharly errore del codice html con javascript durante ottimizzazione websitex5 Javascript 7
O errore INSERT con oggeto datetime MySQL 2
napuleone phpmyadmin problemi con windows 10 errore 200 PHP 0
M errore lettura data nel mysql con funzione Where PHP 1
C Errore con classe PHP 4
1 Errore di istallazione programma vb2010 con access in allegato MS Access 8
C Form con dentro div errore validatore w3c HTML e CSS 6
R Errore di comunicazione con database Mysql PHP 5
asevenx validazione W3C con errore utf-8 HTML e CSS 3
asevenx Errore di connessione e permessi in scrittura file .xml con Aruba Windows Hosting 8
M Errore ListView con ID "android.R.id.list" Sviluppo app per Android 1
J Problema con questo errore Error was: Undefined index: title linea 9 PHP 21
Z Errore con il register PHP 2
E errore php con database mysql PHP 0
V problemi con lock tables (errore 1100) come fare? MySQL 0
A Errore con header ( Location...) PHP 4
F errore con wordpress plug in WordPress 0
valient13 Errore con le emotions [javascript + php] Javascript 0
F Errore configurazione APACHE con PHP Apache 1
neo996sps Errore con script per invio mail PHP 3
M errore in IE con array.style Javascript 0
E errore con internet explorer Windows e Software 2
A errore : "550 cannot stor no permission" per pubblicare il sito con expression web Webdesign e Grafica 0
A errore : "550 cannot stor no permission" per pubblicare il sito con expression web HTML e CSS 1
C Errore 678 con modem alice gate 2 plus wifi Reti LAN e Wireless 3
neo996sps Errore su connessione a DB con VB2008 express Visual Basic 1
asevenx errore con l'inserimento dei dati nel database, campi vuoti Classic ASP 1
G errore con div container HTML e CSS 1
neo996sps Errore visualizzazione sito con explorer HTML e CSS 1
asevenx errore durante l'invio di email con CDONTS Classic ASP 8
F Query con errore Database 3
wer16 errore in ie con float left HTML e CSS 2
Y strano errore con immissione nickname e password PHP 8
G problemi con l'errore 0x80040E14 Classic ASP 4

Discussioni simili