FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour archivo.jpg está dañado
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
archivo.jpg está dañado
Posted: Wed Apr 20, 2016 04:09 PM

Verificación de que un archivo.jpg está dañado a través de FiveWin és posible?

Gracias, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: archivo.jpg está dañado
Posted: Thu Apr 21, 2016 08:42 AM
Hola Joao,

puedes utilizar jpeginfo para comprobar su estado. Alguien que controle c puede pasar el código a FWH.

https://github.com/tjko/jpeginfo

Saludos
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: archivo.jpg está dañado
Posted: Thu Apr 21, 2016 09:14 AM

"Dañado" es un término ambiguo porque podría haber partes del archivo que no estuvieran dañadas y otras que si lo estuvieran.

Se me ocurre que para comprobarlo, se podria abrir con la clase image y ver si es posible obtener el tamaño en pixeles. Si devuelve 0,0 es candidato a erroneo.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: archivo.jpg está dañado
Posted: Fri Apr 22, 2016 12:56 PM
Resuelto,

Code (fw): Select all Collapse
#include "FiveWin.ch"

Function u_Teste()

   //Local cFile := cGetFile( "*.*", "Seleccione um arquivo" )

   local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                            "DIB   (*.dib)| *.dib|" +          ;
                            "PCX   (*.pcx)| *.pcx|"  +         ;
                            "JPEG  (*.jpg)| *.jpg|" +          ;
                            "GIF   (*.gif)| *.gif|"  +         ;
                            "TARGA (*.tga)| *.tga|" +          ;
                            "RLE   (*.rle)| *.rle|" +          ;
                            "All Files (*.*)| *.*"             ;
                           ,"Please select a image file", 4 )

   IF EMPTY( cFile )

      MsgStop( "Please select a image file", "Please select a image file" )

      RETURN NIL

   ENDIF

   If ValidJpg( cFile )

      MsgInfo( "Imagem válida", "Imagem válida" )

   Else

      MsgInfo( "Imagem inválida", "Imagem inválida" )

   EndIf

Return Nil

Static Function ValidJpg(cArq)

Return FITypeFromMemory(MemoRead(cArq)) >= 0

/*
By

Eduardo Motta
EMotta Sistemas - <!-- w --><a class="postlink" href="http://www.emotta.com.br">www.emotta.com.br</a><!-- w -->

<!-- m --><a class="postlink" href="http://fivewin.com.br/index.php?/topic/24614-funcao-para-verificar-jpg-resolvido/">http://fivewin.com.br/index.php?/topic/ ... resolvido/</a><!-- m -->
*/


Gracias, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 632
Joined: Tue Dec 12, 2006 07:34 PM
Re: archivo.jpg está dañado
Posted: Fri Apr 22, 2016 04:22 PM
karinha wrote:Resuelto,

Code (fw): Select all Collapse
#include "FiveWin.ch"

Function u_Teste()

   //Local cFile := cGetFile( "*.*", "Seleccione um arquivo" )

   local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                            "DIB   (*.dib)| *.dib|" +          ;
                            "PCX   (*.pcx)| *.pcx|"  +         ;
                            "JPEG  (*.jpg)| *.jpg|" +          ;
                            "GIF   (*.gif)| *.gif|"  +         ;
                            "TARGA (*.tga)| *.tga|" +          ;
                            "RLE   (*.rle)| *.rle|" +          ;
                            "All Files (*.*)| *.*"             ;
                           ,"Please select a image file", 4 )

   IF EMPTY( cFile )

      MsgStop( "Please select a image file", "Please select a image file" )

      RETURN NIL

   ENDIF

   If ValidJpg( cFile )

      MsgInfo( "Imagem válida", "Imagem válida" )

   Else

      MsgInfo( "Imagem inválida", "Imagem inválida" )

   EndIf

Return Nil

Static Function ValidJpg(cArq)

Return FITypeFromMemory(MemoRead(cArq)) >= 0

/*
By

Eduardo Motta
EMotta Sistemas - <!-- m --><a class="postlink" href="http://www.emotta.com.br">http://www.emotta.com.br</a><!-- m -->

<!-- m --><a class="postlink" href="http://fivewin.com.br/index.php?/topic/24614-funcao-para-verificar-jpg-resolvido/">http://fivewin.com.br/index.php?/topic/ ... resolvido/</a><!-- m -->
*/


Gracias, saludos.



Gracias Ing. Karinha por la rutina, es bueno tenerlo a futuro.

Saludos

Atte: Adrian C. C.

Continue the discussion