Returned ThumbnailSource must be closed.
965970
def thumbnail_source_for_display_item(self, ui, display_item: DisplayItem.DisplayItem) -> ThumbnailSource:
        """"""
        with self.__lock:
            thumbnail_source = self.__thumbnail_sources.get(display_item)
            if not thumbnail_source:
                thumbnail_source = ThumbnailSource(ui, display_item)
                self.__thumbnail_sources[display_item] = thumbnail_source

                def will_delete(thumbnail_source):
                    del self.__thumbnail_sources[thumbnail_source._display_item]

                thumbnail_source._on_will_delete = will_delete
            else:
                assert thumbnail_source._ui == ui
            return thumbnail_source.add_ref()
1124465
private static void closeDB(PersistenceManager pm) {
        if (pm.currentTransaction().isActive()) {
            pm.currentTransaction().rollback();
        }
        pm.close();
        pm.getPersistenceManagerFactory().close();
    }
146588
def get_thumbnail(self, original, size, crop, options):
        
        try:
            image = self.create(original, size, crop, options)
        except ThumbnailError:
            image = None
        finally:
            self.cleanup(original)
        return image
1341430
public ThumbnailDownload getThumbnail(String path, ThumbnailSize size, ThumbnailFormat format) {
        OAuthRequest request = new OAuthRequest(Verb.GET, THUMBNAILS_URL + encode(path));

        if (size != THUMBNAIL_SIZE) {
            request.addQuerystringParameter("size", size.toString());
        }

        if (format != THUMBNAIL_FORMAT) {
            request.addQuerystringParameter("format", format.toString());
        }

        service.signRequest(accessToken, request);
        Response response = checkThumbnails(request.send());

        return new ThumbnailDownload(response, path, size, format);
    }
1298777
function(res) {
      // handle thumbnail
      var picurl = '';
      // TODO: further process to thumbnail according to its size
      if (!res.thumbnail) {
        // if no thumbnail exists, a default pic should be returned.
        picurl = this.conf.CONST.PIC_PLACEHOLDER;
      } else {
        picurl = res.thumbnail.source;
      }
      res.extract = _.trunc(res.extract, {
        'length': this.conf.CONST.EXTRACT_REPLY_LIMIT, 
        'separator': /(，|。|\n)/
      });
      return {
        title: res.title,
        description: res.extract,
        url: this._page_url(res.title),
        picurl: picurl
      };
    }
579070
def cleanup(self):
        
        for key in self._find_keys(identity='image'):
            image_file = self._get(key)

            if image_file and not image_file.exists():
                self.delete(image_file)

        for key in self._find_keys(identity='thumbnails'):
            # We do not need to check for file existence in here since we
            # already did that above for all image references
            image_file = self._get(key)

            if image_file:
                # if there is an image_file then we check all of its thumbnails
                # for existence
                thumbnail_keys = self._get(key, identity='thumbnails') or []
                thumbnail_keys_set = set(thumbnail_keys)

                for thumbnail_key in thumbnail_keys:
                    if not self._get(thumbnail_key):
                        thumbnail_keys_set.remove(thumbnail_key)

                thumbnail_keys = list(thumbnail_keys_set)

                if thumbnail_keys:
                    self._set(key, thumbnail_keys, identity='thumbnails')
                    continue

            # if there is no image_file then this thumbnails key is just
            # hangin' loose, If the thumbnail_keys ended up empty there is no
            # reason for keeping it either
            self._delete(key, identity='thumbnails')
40806
@Subscribe
    public void onThumbnailWritten(ThumbnailWrittenEvent e) {
        try {
            queueOrSubmitUpload(keyForFilename("thumb.jpg"), e.getThumbnailFile());
        } catch (Exception ex) {
            Log.i(TAG, "Error writing thumbanil");
            ex.printStackTrace();
        }
    }
194149
def clear_thumbnails(self):
        ''''''
        state = self.state
        for l in state.layers:
            keys = state.layers[l].keys()[:]
            for key in keys:
                if (isinstance(state.layers[l][key], SlipThumbnail)
                    and not isinstance(state.layers[l][key], SlipIcon)):
                    state.layers[l].pop(key)
1117164
@WorkerThread
    @Nullable
    public String createThumbnailForImage(String imagePath) {
        if (TextUtils.isEmpty(imagePath)) return null;

        File inFile = new File(imagePath);
        if (!inFile.exists()) return null;

        File thumbnailFile = randomPath(imagePath);
        if (thumbnailFile.exists()) return thumbnailFile.getAbsolutePath();

        Bitmap inBitmap = readImageFromPath(imagePath, THUMBNAIL_SIZE, THUMBNAIL_SIZE);
        if (inBitmap == null) return null;

        ByteArrayOutputStream compressStream = new ByteArrayOutputStream();
        inBitmap.compress(Bitmap.CompressFormat.JPEG, THUMBNAIL_QUALITY, compressStream);

        try {
            compressStream.close();
            thumbnailFile.createNewFile();

            FileOutputStream writeStream = new FileOutputStream(thumbnailFile);
            writeStream.write(compressStream.toByteArray());
            writeStream.flush();
            writeStream.close();
            return thumbnailFile.getAbsolutePath();
        } catch (Exception ignored) {
            return null;
        }
    }
185676
function ( item ) {  // function to obtain the URL of the thumbnail image
				var href;

				if (item.element) {
					href = $(item.element).find('img').attr('src');
				}

				if (!href && item.type === 'image' && item.href) {
					href = item.href;
				}

				return href;
			}
663512
private final void closeInternal()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "closeInternal");

    stop(); // stop the stream
    dem.close();
    closed = true;

    // close all the JSRemoteConsumerPoints.
    Enumeration vEnum = consumerKeyTable.elements();
    while (vEnum.hasMoreElements())
    {
      JSRemoteConsumerPoint aock = (JSRemoteConsumerPoint) vEnum.nextElement();
      aock.close();
    }
    consumerKeyTable.clear();

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "closeInternal");
  }
483589
def clear(self):
        
        all_keys = self._find_keys_raw(settings.THUMBNAIL_KEY_PREFIX)
        if all_keys:
            self._delete_raw(*all_keys)
160619
def _closeResources(self):
        
        self.histLutItem.sigLevelsChanged.disconnect(self.setAutoRangeOff)
        self.histLutItem.sigLevelsChanged.disconnect(self.refreshMinMax)
629310
@Override
    public void close() {
        if (trainingArchive != null && trainingArchive != weightsArchive) {
            trainingArchive.close();
            trainingArchive = null;
        }
        if (weightsArchive != null) {
            weightsArchive.close();
            weightsArchive = null;
        }
    }
89650
def thumbs resources, image_url_method, options = {}, &block
      return unless resources.is_a?(Array) || resources.is_a?(ActiveRecord::Relation)
      options[:span] ||= 4
      options[:slice] ||= 12/options[:span]
      ret = "".html_safe

      resources.each_slice(options[:slice]) do |slice|
        ret += content_tag :ul, :class => "thumbnails" do
          slice.inject("".html_safe) do |sum, resource|
            img_url = resource.send(image_url_method)
            url = options[:url_method] ? resource.send(options[:url_method]) : url_for(resource)
            send_args = resource.is_a?(ActiveRecord::Base) ? [:content_tag_for, :li, resource] : [:content_tag, :li]
            send_args << {:class => "span#{options[:span]}"}
            sum + send(*send_args) do
              if block_given?
                content_tag :div, :class => "thumbnail" do
                  image_tag(img_url) + capture(resource, &block)
                end
              else
                link_to image_tag(img_url), url, :class => "thumbnail"
              end
            end
          end
        end
      end
      ret
    end
1252863
@Override
    public void close() {
        if (mIsClosed) {
            return;
        }
        mIsClosed = true;

        mRetrofit = null;
        mRetrofitService = null;
        mRequestSignatorInterceptor = null;
        mHttpLoggingInterceptor = null;

        mApplicationContext.clear();
        mApplicationContext = null;

        mClientKey = null;
    }
845484
def _Close(self):
    """"""
    self._cpio_archive_file_entry = None
    self._cpio_archive_file = None

    self._file_system.Close()
    self._file_system = None