Return-Path: Delivered-To: apmail-jakarta-poi-user-archive@www.apache.org Received: (qmail 10321 invoked from network); 10 Jul 2006 14:29:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Jul 2006 14:29:47 -0000 Received: (qmail 59059 invoked by uid 500); 10 Jul 2006 14:29:41 -0000 Delivered-To: apmail-jakarta-poi-user-archive@jakarta.apache.org Received: (qmail 59040 invoked by uid 500); 10 Jul 2006 14:29:41 -0000 Mailing-List: contact poi-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "POI Users List" Reply-To: "POI Users List" Delivered-To: mailing list poi-user@jakarta.apache.org Received: (qmail 59029 invoked by uid 99); 10 Jul 2006 14:29:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2006 07:29:41 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mr.jonze@gmail.com designates 64.233.166.176 as permitted sender) Received: from [64.233.166.176] (HELO py-out-1112.google.com) (64.233.166.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2006 07:29:34 -0700 Received: by py-out-1112.google.com with SMTP id d80so3896509pyd for ; Mon, 10 Jul 2006 07:29:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=XqiUunhumCg36T1pHXI9dZTBprsSwNhHfQfUVqKmF9YWgV420SdOUp3fDWc+I0djL1GlEgdnGBPd9C4e76KvmmJmHtQG5rMSBS8gjrJSs83WFnd8RM2Ayd0tlJV3rERG9smc9aBk6xbgfH0fCmBc3vOgOniMsmzxMvp4tpbhRX0= Received: by 10.35.85.1 with SMTP id n1mr5086292pyl; Mon, 10 Jul 2006 07:29:06 -0700 (PDT) Received: by 10.35.43.3 with HTTP; Mon, 10 Jul 2006 07:29:06 -0700 (PDT) Message-ID: Date: Mon, 10 Jul 2006 11:29:06 -0300 From: mr.jonze To: "POI Users List" Subject: Re: Re[2]: PPT Pictures In-Reply-To: <97373681953.20060707175921@dinom.ru> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_36339_27316239.1152541746322" References: <2035.200.19.186.19.1151697719.squirrel@webmail.nuts.ufc.br> <45348796.20060703114027@dinom.ru> <97373681953.20060707175921@dinom.ru> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_36339_27316239.1152541746322 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Yes, it works the way it should. Thanks a lot. 2006/7/7, Yegor Kozlov : > > There are two ways to retrieve images from a ppt file: > > 1. Use HSLFSlideShow.getPictureData(). > This method always returns the content of the image stream, > It doesn't know if the images are used in the slides or not. > I would say it corresponds to physical level, not to the logical, i.e. > it returns images that are stored in the ppt file, not the ones that > are actually used. > As Nick says, if you edit your ppt with 'incremental save' option > enabled, HSLFSlideShow.getPictureData() can return previously deleted > images which will be gone on next full resave. > > 2. Iterate over the shapes in a slide and collect Picture shapes. > This approach guarantees that you get only those Pictures that are > actually used: > > Slide[] slide = ppt.getSlides(); > for (int i = 0; i < slide.length; i++) { > Slide sl = slide[i]; > Shape[] sh = sl.getShapes(); > for (int j = 0; j < sh.length; j++) { > Shape shape = sh[j]; > if (shape instanceof Picture){ > Picture picture = (Picture)shape; > > PictureData pict = picture.getPictureData(); > > byte[] data = pict.getData(); > int type = pict.getType(); > > if (type == Picture.JPEG){ > FileOutputStream out = new > FileOutputStream("_slide"+j+".jpg"); > out.write(data); > out.close(); > } else if (type == Picture.PNG){ > FileOutputStream out = new > FileOutputStream("_slide"+j+".png"); > out.write(data); > out.close(); > } > } > } > } > > Yegor > > mj> Hi > > mj> I'd like to report an error that i found while using POI. I was > retrieving > mj> the pictures from a ppt file and saving each one in a file and it was > mj> working ok, but i deleted one of the pictures of the PowerPoint file > and POI > mj> was still saving it in a file. Then I realized that it happens when > the > mj> source file of the picture is NOT a .PNG file. In this case, it > happened > mj> with a .BMP and a .JPG file. > > mj> Any suggestions? > > mj> Thanks, > mj> mr_jonze. > > mj> 2006/7/3, Yegor Kozlov : > >> > >> Hi > >> > >> > For instance, if there are 3 pictures, being 2 of them the same > picture, > >> > the returned vector length is 2. > >> > >> It's how it is supposed to work. HSLFSlideShow.getPictures() returns > the > >> actual array of images contained in the presentation. > >> Each image is included only once regardless of how many times you have > it > >> in the slides. > >> > >> > >> > What can I do to get the real images number? > >> > >> It looks like you need the number of images shapes, not the number of > >> actual images contained in the ppt. > >> > >> See the code: > >> > >> SlideShow ppt = new SlideShow(new HSLFSlideShow("images.ppt")); > >> > >> //images contained in this slide show > >> PictureData[] pict = ppt.getPictureData(); > >> > >> //get the number of image shapes > >> int imageCount = 0; > >> Slide[] slide = ppt.getSlides(); > >> for (int i = 0; i < slide.length; i++) { > >> Shape[] sh = slide[i].getShapes(); > >> for (int j = 0; j < sh.length; j++) { > >> if (sh[j] instanceof Picture) { > >> Picture p = (Picture)sh[j]; > >> PictureData pdata = p.getPictureData(); > >> > >> imageCount++; > >> } > >> } > >> } > >> > >> Since the same image can be placed on several slides imageCount may not > >> equal to pict.length. > >> > >> > >> Yegor > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org > >> Mailing List: http://jakarta.apache.org/site/mail2.html#poi > >> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org > Mailing List: http://jakarta.apache.org/site/mail2.html#poi > The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ > > ------=_Part_36339_27316239.1152541746322--