[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert TIFF to JPEG Extension Issue

Posted on 2010-11-16
5
Medium Priority
?
682 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
  • 3
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 2000 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview

829 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