Solved

Convert TIFF to JPEG Extension Issue

Posted on 2010-11-16
5
654 Views
Last Modified: 2012-05-10
I'm trying to use a SSIS 2008 package to go to a file share folder, retrieve all the files which will be in the Tiff format, and save them to another location (on the same server) so web users can have web access to them.  The catch is these pictures need to be saved as a gif or jpeg (what are some thoughts on .png?).

 I have the below code that is in a SSIS script task.  The SSIS package works, with no errors; however, it saves the tiff files as a Tiff file.  If i use an .aspx environment (I find this easier to test), the files are transfered to the correct folder, however, they don't have an extension (no .jpeg, .tiff, etc.)

 I developed this code on my computer and it works flawlessly, however, once I put it on the production server, this issue started to show up.  The production server doesn't recognize the jpeg or gif format, could this have something to do with it?

 Imports System
Imports System.Data
Imports System.Math
Imports System.Drawing
Imports System.IO
Imports System.Drawing.Imaging.ImageFormat
Imports Microsoft.SqlServer.Dts.Runtime


Public Sub Main()
        Dim StoreFile As Directory
        Dim Directory As String
        Dim Files As String()
        Dim File As String
        Dim bm As Bitmap

        'Asign Save as Location
        Directory = "C:\xx\xx\website\Folder\ChartImages\"

        'Asign the files to variable
        Files = StoreFile.GetFiles("X:\x")

        'Loops through the files
        For Each File In Files
            bm = Bitmap.FromFile(File)
            bm.Save(Directory & System.IO.Path.GetFileName(File) & "", Jpeg)
        Next
End Sub
0
Comment
Question by:badrhino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 34147581
GIF and PNG formats are better for line art or graphic design where the image has large areas of solid colors.

Jpeg is best for photographs and pictures with fine detail.

PNG may be the best option for you if the encoders are installed.
0
 
LVL 1

Author Comment

by:badrhino
ID: 34147616
Thanks for the response and the advice on the file format!

How do I know if the encoder is installed, and if it isn't, how do I do this?

Thanks!
0
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 500 total points
ID: 34147849
When you save the file, it does not look like you are changing the file extension from .tiff to .jpeg.

shouldn't this
bm.Save(Directory & System.IO.Path.GetFileName(File) & "", Jpeg)

be this?
bm.Save(Directory & System.IO.Path.GetFileName(File) & ".JPG", Jpeg)
0
 
LVL 1

Author Comment

by:badrhino
ID: 34147954
Not sure how I missed that, but your correct.  I changed it in my code and it works great.  
Thanks!
0
 
LVL 1

Author Comment

by:badrhino
ID: 34147963
Perhpas I should learn how to type....

Not sure how I missed that, but you're correct.  I changed it in my code and it works great.  
Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question