Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4065136
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:56:42+00:00 2026-05-20T15:56:42+00:00

I need to delete a page from a multipaged TIFF file. I am currently

  • 0

I need to delete a page from a multipaged TIFF file. I am currently working in .NET but can move to another language if some one knows how to do it in that language.

The page would be either the second to last, or the last page in the file. And I need to do it with out decompressing the previous pages in the file, so not creating a new TIFF and copying all the pages I still want to that.

I have code that does that already, but as the TIFF files I am working with are around 1.0 gb – 3.0 gb heavily compressed, this is extremely time consuming. If I can just remove the part of the file that I want and not create a new one that will go much faster.

The page that I need to remove is very very small compared to the rest of the file, as is the page that may or may not be after it, around 500*500 pixels.

What I have tried, I have tried the LibTiff.Net library, found here

http://bitmiracle.com/libtiff/

After messing with it for awhile I asked the developer about my issue, they said that there wasn’t currently support to do that. I also looked into ImageMagick a bit, but I haven’t been able to figure out how to do this there either.

Any one got any helpful ideas here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:56:43+00:00Added an answer on May 20, 2026 at 3:56 pm

    Ok, got a solution working in python.

    import mmap
    from struct import *
    
    def main():
        filename = raw_input("Input file name: ")
        f = open(filename, "r+b")
        offList, compList = getOffsets(f)
        for i in range(len(offList)):
            print "offset: ", offList[i], "\t Compression: ", compList[i]
        print "ran right"
        stripLabelAndMacro(f, offList, 3)
        offList, compList = getOffsets(f)
        for i in range(len(offList)):
            print "offset: ", offList[i], "\t Compression: ", compList[i]
        f.close()
        #test stripping end crap
    
    def getOffsets(f):
        fmap = mmap.mmap(f.fileno(),0)
        offsets = []
        compressions = []
        #get TIFF version
        ver = int(unpack('H', fmap[2:4])[0])
        if ver == 42:
            #get first IDF
            offset = long(unpack('L', fmap[4:8])[0])
            while (offset != 0):
                offsets.append(offset)
                #get number of tags in this IDF
                tags = int(unpack('H', fmap[offset:offset+2])[0])
                i = 0
                while (i<tags):
                    tagID = int(unpack('H',fmap[offset+2:offset+4])[0])
                    #if the tag is a compression, get the compression SHORT value and
                    #if recognized use a string representation
                    if tagID == 259:
                        tagValue = int(unpack('H', fmap[offset+10:offset+12])[0])
                        if tagValue == 1:
                            compressions.append("None")
                        elif tagValue == 5:
                            compressions.append("LZW")
                        elif tagValue == 6:
                            compressions.append("JPEG")
                        elif tagValue == 7:
                            compressions.append("JPEG")
                        elif tagValue == 34712 or tagValue == 33003 or tagValue == 33005:
                            compressions.append("JP2K")
                        else:
                            compressions.append("Unknown")
                    i+=1
                    offset += 12
    
                offset = long(unpack('L', fmap[offset+2:offset+6])[0])
        return offsets, compressions
    
    #Tested, Doesn't break TIFF
    def stripLabel(f, offsetList, labelIndex):
        fmap = mmap.mmap(f.fileno(),0)
        offsetLabel = offsetList[labelIndex]
        offsetMacro = offsetList[labelIndex+1]
        offsetEnd = fmap.size()
        macroSize = offsetEnd - offsetMacro
        for i in range(macroSize):
            fmap[offsetLabel+i] = fmap[offsetMacro+i]
        fmap.flush()
        fmap.resize(offsetLabel+macroSize-1)
        fmap.close()
    

    Tested it, seems to work fine. the stripLabel method is specifically meant to remove the second to last page/directory and shift the last one up, but it should in theory work for any directory other than the last, and it could be easily modified to remove the last too. It requires at least the amount of free ram as the file size you are working on, but it runs fast and file size isn’t an issue with most TIFF’s. It isn’t the most elegant approach, if some one has another please post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In need to move/delete files on the local file system of the user from
I need to delete a temporary file from my C++ windows application (developed in
I need to delete some Unicode symbols from the string 'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'
I need to delete my input file securely once I have finished with it,
I need to delete files of a certain type (.zip files, say) from a
I have the need from an asp.net web site to send out many SMS
my URL looks like page.html?L=0&a=1&b=2&c=6 OR page.html?a=1&b=2&L=0&c=6 OR page.html?a=1&b=2&c=6&L=0 I need to delete the
I need to delete a regsitry key. It has a deny ACL on Set
The array has lots of data and I need to delete two elements. Below
I am using Qt Dialogs in one of my application. I need to hide/delete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.