Ooops
November 28, 2020, 02:04:09 AM

Author Topic: [bb] Thumbnail Creator by -=Darkheart=- [ 1+ years ago ]  (Read 646 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Thumbnail Creator by -=Darkheart=- [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
Title : Thumbnail Creator
Author : -=Darkheart=-
Posted : 1+ years ago

Description : Creates Thumbnail images (any size) of any loadable image file,  (Includes batch convertor for directories).

Code :
Code: BlitzBasic
  1. ;#####################################################################################
  2. ;################################                          ###########################
  3. ;################################     Thumbnail Creator    ###########################
  4. ;################################                          ###########################
  5. ;#####################################################################################
  6. ;
  7. ;A program that creates thumbnail images.
  8. ;
  9. ;Written by Darkheart 23/6/03
  10. ;
  11. ;Open Source and Freeware
  12. ;
  13. Graphics 800,600,32,2
  14. SetBuffer BackBuffer()
  15. AppTitle "Thumbnail Creator Version 1 by Darkheart"
  16.  
  17. ;File and Path Functions courtsey of Rob (see archieves)
  18.  
  19. Function bbGetDir$(path$)
  20.         For a = Len(path$) To 1 Step -1
  21.                 byte$ = Mid(path$,a,1)
  22.                 If byte$ = ""
  23.                         Return Left(path$,a)
  24.                 EndIf
  25.         Next
  26.         Return ""
  27. End Function
  28.  
  29.  
  30. Function bbGetFile$(path$)
  31.         For a = Len(path$) To 1 Step -1
  32.                 byte$ = Mid(path$,a,1)
  33.                 If byte$ = ""
  34.                         Return Right(path$,Len(path$)-a)
  35.                 EndIf
  36.         Next
  37.         Return path$
  38. End Function
  39.  
  40. Print "Enter filename and full path if not in same directory as program."
  41. Print "Enter ALL to produce thumbnails for all files in that directory."
  42. Print "e.g. c:picsmypic.bmp or c:picsall"
  43. Print ""
  44. Print "Resized images will be saved as t_<image name>"
  45. Print "e.g. boat.bmp will have thumbnail t_boat.bmp"
  46. FILE$=Input ("Filename and Path: ")
  47. thedir$=bbgetdir$(FILE$)
  48. thefile$=bbgetfile$(FILE$)
  49. c=FileType (thedir$)
  50.  
  51.         If c<>2 Then
  52.         Print "Path does not exist!"
  53.         Delay 3000
  54.         End
  55. EndIf
  56.  
  57. b=FileType(FILE$)
  58.  
  59. allfiles=0
  60.         If thefile$="all" Or thefile$="ALL" Then allfiles=1
  61.        
  62.         If allfiles=0 And b=0 Then
  63.         Print "File not Found!"
  64.         Delay 3000
  65.         End
  66. EndIf
  67.  
  68. Print ""
  69. height#=Input("Enter desiered thumbnail hieght: ")
  70. width#=Input ("Enter desiered thumbnail width: ")
  71.  
  72. Select allfiles
  73.  
  74. ;If there is only 1 file then convert and save as t_<filename>.bmp.
  75.  
  76.         Case 0
  77.         thisimage=LoadImage (file$)
  78.         ResizeImage thisimage,width,height
  79.        
  80.         newfile$="t_"+thefile$
  81.         k=Len(newfile$)
  82.         newfile$=Left$(newfile$,k-4)
  83.         newfile$=newfile$+".bmp"
  84.                
  85.         fileandpath$=thedir$+newfile$
  86.         SaveImage thisimage,fileandpath$
  87.        
  88. ;If we are converting all files in the directory loop through the directory and convert all files
  89. ;as above.
  90.        
  91.         Case 1
  92.         ThisDir=ReadDir (thedir$)
  93.         ChangeDir thedir$
  94.         Repeat
  95.        
  96.         thisfile$=NextFile(ThisDir)
  97.                 If thisfile="" Then Exit
  98.        
  99.         isfile=FileType (thisfile$)
  100.                 If isfile=1 And Left$(thisfile$,2)<>"t_" Then
  101.                 Print "Processing File: " + thisfile$
  102.                 thisimage=LoadImage (thisfile$)
  103.                 ResizeImage thisimage,width,height
  104.                 newfile$="t_"+thisfile$
  105.                 k=Len(newfile$)
  106.                 newfile$=Left$(newfile$,k-4)
  107.                 newfile$=newfile$+".bmp"       
  108.                 fileandpath$=thedir$+newfile$
  109.                 SaveImage thisimage,fileandpath$
  110.                 Print "Saved File: " + fileandpath$
  111.         EndIf
  112.         Forever
  113.        
  114.        
  115. End Select
  116. Print ""
  117. Print "All files Done!"
  118. Delay 3000
  119. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal