コード例 #1
0
ファイル: gui.py プロジェクト: hi117/image-database
    def displayImage(self,button):
        '''
        This function displays the image given a button.
        '''
        Hash = button.get_label()
        curImage = tempfile.NamedTemporaryFile(buffering = 0)
        curImage.write(p.extractImage(Hash))

        # TODO: Scale gifs.
        if 'GIF' in p._idb.images[Hash][1]:
            pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(curImage.name)
            self.img.set_from_animation(pixbuf)
        else:
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(curImage.name)
            size = self.img.get_allocation()
            imgSize = [pixbuf.get_width(), pixbuf.get_height()]

            # determine how to scale to keep aspect ratio
            wRatio = size.width / float(imgSize[0])
            hRatio = size.height / float(imgSize[1])
            if wRatio<hRatio:
                imgSize[0] = imgSize[0] * wRatio
                imgSize[1] = imgSize[1] * wRatio
            else:
                imgSize[0] = imgSize[0] * hRatio
                imgSize[1] = imgSize[1] * hRatio
            scaled_buf = pixbuf.scale_simple(int(imgSize[0]), int(imgSize[1]), GdkPixbuf.InterpType.HYPER)
            self.img.set_from_pixbuf(scaled_buf)
        curImage.close()

        # set the hash box to the correct value
        self.tagBar.set_text(', '.join(p.getImagesAll()[Hash][2]))
        self.tagBar.set_position(-1)
コード例 #2
0
ファイル: gui.py プロジェクト: hi117/image-database
 def extractPicture(self,button):
     '''
     This function extracts a picture from the database to a given location.
     '''
     path=getFileWrite()
     for button in self.pictures:
         if button.get_active():
             open(path,'wb').write(p.extractImage(button.get_label()))
             break
コード例 #3
0
ファイル: mass_extract.py プロジェクト: hi117/image-database
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from sys import exit,argv
import pictures as p
import os
import os.path

def genPath(Hash):
    image = p._idb.images[Hash]
    return Hash + ' - ' + ', '.join(image[2]) + '.' + image[1].split(' ')[0]

if len(argv) != 3:
    print("usage: python mass_extract.py db.ksh directory")
    exit(0)

if not os.path.isdir(argv[2]):
    print("error: pah given is dot a directory")
    exit(1)

p._idb = p.idb.db(argv[1])
os.chdir(argv[2])
for picture in p.getImages():
    try:
        open(genPath(picture), 'wb').write(p.extractImage(picture))
    except TypeError:
        print(picture)
コード例 #4
0
ファイル: extract.py プロジェクト: hi117/image-database
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from sys import exit,argv
import pictures as p
import os
import os.path

def genPath(Hash):
    image = p._idb.images[Hash]
    return Hash + ' - ' + ', '.join(image[2]) + '.' + image[1].split(' ')[0]


if len(argv) != 4:
    print("usage: mass_extract.py db.ksh hash directory")
    exit(0)

if not os.path.isdir(argv[3]):
    print("error: pah given is dot a directory")
    exit(1)

p._idb = p.idb.db(argv[1])
os.chdir(argv[3])
open(genPath(argv[2]), 'wb').write(p.extractImage(argv[2]))