Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    A generic error occurred in GDI+. Salvataggio immagine

    Ho fatto uno script che prende delle immagini che ho in svariate cartelle e dopo averle ridimensionate le salva ma al momento di salvare mi da quest'errore

    System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

    sulla riga:
    newImage.Save(destPath, ImageFormat.Gif)


    Ecco lo script:
    !------------------------------------------------
    <%@ Import Namespace="System.Drawing"%>
    <%@ Import Namespace="System.Drawing.Imaging"%>
    <%@ Import Namespace="System.Data.Odbc"%>
    <%@ Import Namespace="System.Runtime.InteropServices"%>
    <%@ Import Namespace="System.IO"%>


    Sub Page_Load(sender as Object,e as EventArgs)
    response.contenttype="image/gif"
    Dim destPath as String
    Dim MemStream As New MemoryStream()
    Dim i, j, n_foto, n_case, height, width as Integer
    Dim oldImage, newImage as System.Drawing.Image
    Dim myConnection = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=xxxxxx; UID=xxxxxx; PASSWORD=xxxxxx; OPTION=3")
    myConnection.Open()
    Dim myCommand as OdbcCommand
    myCommand= new OdbcCommand("SELECT COUNT(*) FROM tabella", myConnection)
    n_case = myCommand.ExecuteScalar()
    For i = 1 to n_case
    myCommand = new OdbcCommand("SELECT campo FROM tabella WHERE house_num=" & i & ";", myConnection)
    n_foto = myCommand.ExecuteScalar()
    if n_foto <> 0 then
    For j=1 to n_foto
    oldImage = System.Drawing.Image.FromFile( Server.MapPath("archivio/rurale/" & i & "/foto" & j & ".gif"))
    if oldImage.width>550 then
    width=150
    height=105
    else
    width=105
    height=150
    end if
    destPath="archivio/rurale/" & i & "/foto" & j & "_min.gif"
    newImage = oldImage.GetThumbnailImage( width, height, nothing, IntPtr.Zero)
    newImage.Save(destPath, ImageFormat.Gif)
    next j
    end if
    next i


    End Sub
    !--------------------------------------

    Se mi poteste aiutare ve ne sarei molto grato!

  2. #2
    Problema risolto... sulla path del Save andava messo Server.MapPath

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    Originariamente inviato da navarro87
    Problema risolto... sulla path del Save andava messo Server.MapPath
    sono contento per te.
    per le prossime volte che metti il codice di uno script utilizza il tag [code]

  4. #4
    Originariamente inviato da sms
    sono contento per te.
    per le prossime volte che metti il codice di uno script utilizza il tag [code]
    Scusatemi ma me ne sono accorto troppo tardi e non potevo più modificare il messaggio

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.